Identifying high-conflict cache lines in transactional memory computing environments

ABSTRACT

Cache lines in a computing environment with transactional memory are configurable with a coherency mode and are associated with a high-conflict indicator. Cache lines in full-line coherency mode are operated or managed with full-line granularity. Cache lines in sub-line coherency mode are operated or managed as sub-cache line portions of a full cache line. A cache line is placed in sub-line coherency mode based on examining the high-conflict indicator. A transaction accessing a memory address in a cache line in sub-line coherency mode marks only the sub-cache line portion associated with the memory address as transactionally accessed. The high-conflict indicator may be included in a set of descriptive bits associated with the cache line. A copy of the high-conflict indicator for a cache line in a first cache may be updated with the high-conflict indicator for the cache line in a second cache.

BACKGROUND

This disclosure relates generally to cache management in amulti-processor computing environment, and more specifically to dynamiccoherency protocol granularity modification for individual cache linesin a multi-processor computing environment with transactional memory.

The number of central processing unit (CPU) cores on a chip and thenumber of CPU cores connected to a shared memory continues to growsignificantly to support growing workload capacity demand. Theincreasing number of CPUs cooperating to process the same workloads putsa significant burden on software scalability; for example, shared queuesor data-structures protected by traditional semaphores become hot spotsand lead to sub-linear n-way scaling curves. Traditionally this has beencountered by implementing finer-grained locking in software, and withlower latency/higher bandwidth interconnects in hardware. Implementingfine-grained locking to improve software scalability can be verycomplicated and error-prone, and at today's CPU frequencies, thelatencies of hardware interconnects are limited by the physicaldimension of the chips and systems, and by the speed of light.

Implementations of hardware Transactional Memory (TM) have beenintroduced, wherein a group of instructions, called a transaction,operate atomically and in isolation (sometimes called “serializability”)on a data structure in memory. The transaction executes optimisticallywithout obtaining a lock, but may need to abort and retry thetransaction execution if an operation, of the executing transaction, ona memory location conflicts with another operation on the same memorylocation. Previously, software transactional memory implementations havebeen proposed to support software Transactional Memory (TM). However,hardware TM can provide improved performance aspects and ease of useover software TM.

U.S. Patent Application Publication No 2004/0044850 titled “Method andApparatus for the Synchronization of Distributed Caches” filed 2002 Aug.28, incorporated herein by reference in its entirety, teaches ahierarchical caching protocol suitable for use with distributed caches,including use within a caching input/output hub.

U.S. Pat. No. 5,586,297 titled “Partial Cache Line Write Transactions ina Computing System with a Write Back Cache” filed 1994 Mar. 24,incorporated herein by reference in its entirety, teaches a computingsystem which includes a memory, an input/output adapter and a processor.The processor includes a write back cache in which dirty data may bestored. When performing a coherent write from the input/output adapterto the memory, a block of data is written from the input/output adapterto a memory location within the memory. The block of data contains lessdata than a full cache line in the write back cache. The write backcache is searched to determine whether the write back cache containsdata for the memory location. When the search determines that the writeback cache contains data for the memory location, a full cache linewhich contains the data for the memory location is purged.

SUMMARY

Disclosed herein are embodiments of a method for reducing transactionconflicts in a computing environment with transactional memory. Thecomputing environment includes a cache configured to hold a plurality ofcache lines. Each cache line is configurable with a coherency mode, andeach cache line is associated with a high-conflict indicator.

The high-conflict indicator associated with a first cache line isexamined. Based on examining the high-conflict indicator, the firstcache line is placed in sub-line coherency mode. Cache control logicassociated with the cache is configured to operate or manage a pluralityof sub-cache line portions of the first cache line in sub-line coherencymode.

A transaction is executed in the computing environment. The transactionaccesses a memory address within the first cache line. Only a relevantsub-cache line portion of the first cache line in sub-line coherencymode is accessed and managed while executing the transaction. Therelevant sub-cache line portion is associated with the memory address.

In some embodiments, the high-conflict indicator is included in aplurality of descriptive bits associated with the first cache line in afirst cache. Before examining the high-conflict indicator in the firstcache, a copy of the first cache line in a second cache may bedetermined to be a high-conflict cache line and the high-conflictindicator may be set in that second cache. The copy in the first cachemay then be updated with the copy from the second cache, including theupdated high-conflict indicator. A subsequent update of the copy in thefirst cache may reset the high-conflict indicator, returning the firstcache line to full-line coherency mode.

Also disclosed herein are embodiments of a computer system with a memoryand a processor in communication with the memory. The computer system isconfigured to perform the method described above. Also disclosed hereinare embodiments of a computer program product with a computer readablestorage medium readable by a processing circuit and storing instructionsfor execution by the processing circuit. The instructions are forperforming the method described above.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 depicts an example multicore Transactional Memory environment.

FIG. 2 depicts example components of an example CPU.

FIG. 3 depicts a pictorial representation of a data processing system,which includes an illustrative write-back cache.

FIG. 4 depicts a pictorial representation of an illustrative write-backcache in a data processing system.

FIG. 5 is a flow diagram illustrating an example method for maintainingcache coherency with a data processing system.

FIG. 6 is a block diagram of an example variable line-size cache.

FIG. 7 is a block diagram of an example direct-mapped variable line-sizecache.

FIG. 8 is a block diagram of an example direct-mapped variable line-sizecache with four subarrays.

FIG. 9 is a flow diagram illustrating an example method for detectingand reducing transaction conflicts.

FIG. 10 is a flow diagram illustrating an example method for cachemanagement.

FIG. 11 is a block diagram representing an example system foridentifying high-contention cache lines.

FIG. 12 is a flow diagram illustrating an example method for identifyingproblematic cache lines.

FIG. 13 is a flow diagram illustrating an example method for cachemanagement.

FIG. 14 is a block diagram representing an example computing environmentfor identifying high-contention cache lines.

FIG. 15 is a block diagram representing an example computing environmentfor centralized detection of problematic cache lines.

FIG. 16 is a flow diagram illustrating an example method for centralizeddetection of problematic cache lines.

FIG. 17 is a block diagram representing an example cache structure forproviding sub-line cache management.

FIG. 18 is a flow diagram illustrating an example method for providingsub-line cache management.

FIG. 19 is a block diagram of an example computer program product.

In the figures and description, like numbers generally refer to likecomponents, parts, steps, functional blocks, and processes.

DETAILED DESCRIPTION

Transaction Execution in Intel® Based Embodiments

In “Intel® Architecture Instruction Set Extensions ProgrammingReference” 319433-012A, February 2012, incorporated herein by referencein its entirety, Chapter 8 teaches, in part, that multithreadedapplications may take advantage of increasing numbers of CPU cores toachieve higher performance. However, the writing of multi-threadedapplications requires programmers to understand and take into accountdata sharing among the multiple threads. Access to shared data typicallyrequires synchronization mechanisms. These synchronization mechanismsare used to ensure that multiple threads update shared data byserializing operations that are applied to the shared data, oftenthrough the use of a critical section that is protected by a lock. Sinceserialization limits concurrency, programmers try to limit the overheaddue to synchronization.

Intel® Transactional Synchronization Extensions (Intel® TSX) allow aprocessor to dynamically determine whether threads need to be serializedthrough lock-protected critical sections, and to perform thatserialization only when required. This allows the processor to exposeand exploit concurrency that is hidden in an application because ofdynamically unnecessary synchronization.

With Intel TSX, programmer-specified code regions (also referred to as“transactional regions” or just “transactions”) are executedtransactionally. If the transactional execution completes successfully,then all memory operations performed within the transactional regionwill appear to have occurred instantaneously when viewed from otherprocessors. A processor makes the memory operations of the executedtransaction, performed within the transactional region, visible to otherprocessors only when a successful commit occurs, i.e., when thetransaction successfully completes execution. This process is oftenreferred to as an atomic commit.

Intel TSX provides two software interfaces to specify regions of codefor transactional execution. Hardware Lock Elision (HLE) is a legacycompatible instruction set extension (comprising the XACQUIRE andXRELEASE prefixes) to specify transactional regions. RestrictedTransactional Memory (RTM) is a new instruction set interface(comprising the XBEGIN, XEND, and XABORT instructions) for programmersto define transactional regions in a more flexible manner than thatpossible with HLE. HLE is for programmers who prefer the backwardcompatibility of the conventional mutual exclusion programming model andwould like to run HLE-enabled software on legacy hardware but would alsolike to take advantage of the new lock elision capabilities on hardwarewith HLE support. RTM is for programmers who prefer a flexible interfaceto the transactional execution hardware. In addition, Intel TSX alsoprovides an XTEST instruction. This instruction allows software to querywhether the logical processor is transactionally executing in atransactional region identified by either HLE or RTM.

Since a successful transactional execution ensures an atomic commit, theprocessor executes the code region optimistically without explicitsynchronization. If synchronization was unnecessary for that specificexecution, execution can commit without any cross-thread serialization.If the processor cannot commit atomically, then the optimistic executionfails. When this happens, the processor will roll back the execution, aprocess referred to as a transactional abort. On a transactional abort,the processor will discard all updates performed in the memory regionused by the transaction, restore architectural state to appear as if theoptimistic execution never occurred, and resume executionnon-transactionally.

A processor can perform a transactional abort for numerous reasons. Aprimary reason to abort a transaction is due to conflicting memoryaccesses between the transactionally executing logical processor andanother logical processor. Such conflicting memory accesses may preventa successful transactional execution. Memory addresses read from withina transactional region constitute the read-set of the transactionalregion and addresses written to within the transactional regionconstitute the write-set of the transactional region. Intel TSXmaintains the read- and write-sets at the granularity of a cache line. Aconflicting memory access occurs if another logical processor eitherreads a location that is part of the transactional region's write-set orwrites a location that is a part of either the read- or write-set of thetransactional region. A conflicting access typically means thatserialization is required for this code region. Since Intel TSX detectsdata conflicts at the granularity of a cache line, unrelated datalocations placed in the same cache line will be detected as conflictsthat result in transactional aborts. Transactional aborts may also occurdue to limited transactional resources. For example, the amount of dataaccessed in the region may exceed an implementation-specific capacity.Additionally, some instructions and system events may causetransactional aborts. Frequent transactional aborts result in wastedcycles and increased inefficiency.

Hardware Lock Elision

Hardware Lock Elision (HLE) provides a legacy compatible instruction setinterface for programmers to use transactional execution. HLE providestwo new instruction prefix hints: XACQUIRE and XRELEASE.

With HLE, a programmer adds the XACQUIRE prefix to the front of theinstruction that is used to acquire the lock that is protecting thecritical section. The processor treats the prefix as a hint to elide thewrite associated with the lock acquire operation. Even though the lockacquire has an associated write operation to the lock, the processordoes not add the address of the lock to the transactional region'swrite-set nor does it issue any write requests to the lock. Instead, theaddress of the lock is added to the read-set. The logical processorenters transactional execution. If the lock was available before theXACQUIRE prefixed instruction, then all other processors will continueto see the lock as available afterwards. Since the transactionallyexecuting logical processor neither added the address of the lock to itswrite-set nor performed externally visible write operations to the lock,other logical processors can read the lock without causing a dataconflict. This allows other logical processors to also enter andconcurrently execute the critical section protected by the lock. Theprocessor automatically detects any data conflicts that occur during thetransactional execution and will perform a transactional abort ifnecessary.

Even though the eliding processor did not perform any external writeoperations to the lock, the hardware ensures program order of operationson the lock. If the eliding processor itself reads the value of the lockin the critical section, it will appear as if the processor had acquiredthe lock, i.e. the read will return the non-elided value. This behaviorallows an HLE execution to be functionally equivalent to an executionwithout the HLE prefixes.

An XRELEASE prefix can be added in front of an instruction that is usedto release the lock protecting a critical section. Releasing the lockinvolves a write to the lock. If the instruction is to restore the valueof the lock to the value the lock had prior to the XACQUIRE prefixedlock acquire operation on the same lock, then the processor elides theexternal write request associated with the release of the lock and doesnot add the address of the lock to the write-set. The processor thenattempts to commit the transactional execution.

With HLE, if multiple threads execute critical sections protected by thesame lock but they do not perform any conflicting operations on eachother's data, then the threads can execute concurrently and withoutserialization. Even though the software uses lock acquisition operationson a common lock, the hardware recognizes this, elides the lock, andexecutes the critical sections on the two threads without requiring anycommunication through the lock—if such communication was dynamicallyunnecessary.

If the processor is unable to execute the region transactionally, thenthe processor will execute the region non-transactionally and withoutelision. HLE enabled software has the same forward progress guaranteesas the underlying non-HLE lock-based execution. For successful HLEexecution, the lock and the critical section code must follow certainguidelines. These guidelines only affect performance; and failure tofollow these guidelines will not result in a functional failure.Hardware without HLE support will ignore the XACQUIRE and XRELEASEprefix hints and will not perform any elision since these prefixescorrespond to the REPNE/REPE IA-32 prefixes which are ignored on theinstructions where XACQUIRE and XRELEASE are valid. Importantly, HLE iscompatible with the existing lock-based programming model. Improper useof hints will not cause functional bugs though it may expose latent bugsalready in the code.

Restricted Transactional Memory (RTM) provides a flexible softwareinterface for transactional execution. RTM provides three newinstructions—XBEGIN, XEND, and XABORT—for programmers to start, commit,and abort a transactional execution.

The programmer uses the XBEGIN instruction to specify the start of atransactional code region and the XEND instruction to specify the end ofthe transactional code region. If the RTM region could not besuccessfully executed transactionally, then the XBEGIN instruction takesan operand that provides a relative offset to the fallback instructionaddress.

A processor may abort RTM transactional execution for many reasons. Inmany instances, the hardware automatically detects transactional abortconditions and restarts execution from the fallback instruction addresswith the architectural state corresponding to that present at the startof the XBEGIN instruction and the EAX register updated to describe theabort status.

The XABORT instruction allows programmers to abort the execution of anRTM region explicitly. The XABORT instruction takes an 8-bit immediateargument that is loaded into the EAX register and will thus be availableto software following an RTM abort. RTM instructions do not have anydata memory location associated with them. While the hardware providesno guarantees as to whether an RTM region will ever successfully committransactionally, most transactions that follow the recommendedguidelines are expected to successfully commit transactionally. However,programmers must always provide an alternative code sequence in thefallback path to guarantee forward progress. This may be as simple asacquiring a lock and executing the specified code regionnon-transactionally. Further, a transaction that always aborts on agiven implementation may complete transactionally on a futureimplementation. Therefore, programmers must ensure the code paths forthe transactional region and the alternative code sequence arefunctionally tested.

Detection of HLE Support

A processor supports HLE execution if CPUID.07H.EBX.HLE [bit 4]=1.However, an application can use the HLE prefixes (XACQUIRE and XRELEASE)without checking whether the processor supports HLE. Processors withoutHLE support ignore these prefixes and will execute the code withoutentering transactional execution.

Detection of RTM Support

A processor supports RTM execution if CPUID.07H.EBX.RTM [bit 11]=1. Anapplication must check if the processor supports RTM before it uses theRTM instructions (XBEGIN, XEND, XABORT). These instructions willgenerate a #UD exception when used on a processor that does not supportRTM.

Detection of XTEST Instruction

A processor supports the XTEST instruction if it supports either HLE orRTM. An application must check either of these feature flags beforeusing the XTEST instruction. This instruction will generate a #UDexception when used on a processor that does not support either HLE orRTM.

Querying Transactional Execution Status

The XTEST instruction can be used to determine the transactional statusof a transactional region specified by HLE or RTM. Note, while the HLEprefixes are ignored on processors that do not support HLE, the XTESTinstruction will generate a #UD exception when used on processors thatdo not support either HLE or RTM.

Requirements for HLE Locks

For HLE execution to successfully commit transactionally, the lock mustsatisfy certain properties and access to the lock must follow certainguidelines.

An XRELEASE prefixed instruction must restore the value of the elidedlock to the value it had before the lock acquisition. This allowshardware to safely elide locks by not adding them to the write-set. Thedata size and data address of the lock release (XRELEASE prefixed)instruction must match that of the lock acquire (XACQUIRE prefixed) andthe lock must not cross a cache line boundary.

Software should not write to the elided lock inside a transactional HLEregion with any instruction other than an XRELEASE prefixed instruction,otherwise such a write may cause a transactional abort. In addition,recursive locks (where a thread acquires the same lock multiple timeswithout first releasing the lock) may also cause a transactional abort.Note that software can observe the result of the elided lock acquireinside the critical section. Such a read operation will return the valueof the write to the lock.

The processor automatically detects violations to these guidelines, andsafely transitions to a non-transactional execution without elision.Since Intel TSX detects conflicts at the granularity of a cache line,writes to data collocated on the same cache line as the elided lock maybe detected as data conflicts by other logical processors eliding thesame lock.

Transactional Nesting

Both HLE and RTM support nested transactional regions. However, atransactional abort restores state to the operation that startedtransactional execution: either the outermost XACQUIRE prefixed HLEeligible instruction or the outermost XBEGIN instruction. The processortreats all nested transactions as one transaction.

HLE Nesting and Elision

Programmers can nest HLE regions up to an implementation specific depthof MAX_HLE_NEST_COUNT. Each logical processor tracks the nesting countinternally but this count is not available to software. An XACQUIREprefixed HLE-eligible instruction increments the nesting count, and anXRELEASE prefixed HLE-eligible instruction decrements it. The logicalprocessor enters transactional execution when the nesting count goesfrom zero to one. The logical processor attempts to commit only when thenesting count becomes zero. A transactional abort may occur if thenesting count exceeds MAX_HLE_NEST_COUNT.

In addition to supporting nested HLE regions, the processor can alsoelide multiple nested locks. The processor tracks a lock for elisionbeginning with the XACQUIRE prefixed HLE eligible instruction for thatlock and ending with the XRELEASE prefixed HLE eligible instruction forthat same lock. The processor can, at any one time, track up to aMAX_HLE_ELIDED_LOCKS number of locks. For example, if the implementationsupports a MAX_HLE_ELIDED_LOCKS value of two and if the programmer neststhree HLE identified critical sections (by performing XACQUIRE prefixedHLE eligible instructions on three distinct locks without performing anintervening XRELEASE prefixed HLE eligible instruction on any one of thelocks), then the first two locks will be elided, but the third won't beelided (but will be added to the transaction's writeset). However, theexecution will still continue transactionally. Once an XRELEASE for oneof the two elided locks is encountered, a subsequent lock acquiredthrough the XACQUIRE prefixed HLE eligible instruction will be elided.

The processor attempts to commit the HLE execution when all elidedXACQUIRE and XRELEASE pairs have been matched, the nesting count goes tozero, and the locks have satisfied requirements. If execution cannotcommit atomically, then execution transitions to a non-transactionalexecution without elision as if the first instruction did not have anXACQUIRE prefix.

RTM Nesting

Programmers can nest RTM regions up to an implementation specificMAX_RTM_NEST_COUNT. The logical processor tracks the nesting countinternally but this count is not available to software. An XBEGINinstruction increments the nesting count, and an XEND instructiondecrements the nesting count. The logical processor attempts to commitonly if the nesting count becomes zero. A transactional abort occurs ifthe nesting count exceeds MAX_RTM_NEST_COUNT.

Nesting HLE and RTM

HLE and RTM provide two alternative software interfaces to a commontransactional execution capability. Transactional processing behavior isimplementation specific when HLE and RTM are nested together, e.g., HLEis inside RTM or RTM is inside HLE. However, in all cases, theimplementation will maintain HLE and RTM semantics. An implementationmay choose to ignore HLE hints when used inside RTM regions, and maycause a transactional abort when RTM instructions are used inside HLEregions. In the latter case, the transition from transactional tonon-transactional execution occurs seamlessly since the processor willre-execute the HLE region without actually doing elision, and thenexecute the RTM instructions.

Abort Status Definition

RTM uses the EAX register to communicate abort status to software.Following an RTM abort the EAX register has the following definition.

TABLE 1 RTM Abort Status Definition EAX Register Bit Position Meaning 0Set if abort caused by XABORT instruction 1 If set, the transaction maysucceed on retry, this bit is always clear if bit 0 is set 2 Set ifanother logical processor conflicted with a memory address that was partof the transaction that aborted 3 Set if an internal buffer overflowed 4Set if a debug breakpoint was hit 5 Set if an abort occurred duringexecution of a nested transaction 23:6 Reserved 31-24 XABORT argument(only valid if bit 0 set, otherwise reserved)

The EAX abort status for RTM only provides causes for aborts. It doesnot by itself encode whether an abort or commit occurred for the RTMregion. The value of EAX can be 0 following an RTM abort. For example, aCPUID instruction when used inside an RTM region causes a transactionalabort and may not satisfy the requirements for setting any of the EAXbits. This may result in an EAX value of 0.

RTM Memory Ordering

A successful RTM commit causes all memory operations in the RTM regionto appear to execute atomically. A successfully committed RTM regionconsisting of an XBEGIN followed by an XEND, even with no memoryoperations in the RTM region, has the same ordering semantics as a LOCKprefixed instruction.

The XBEGIN instruction does not have fencing semantics. However, if anRTM execution aborts, then all memory updates from within the RTM regionare discarded and are not made visible to any other logical processor.

RTM-Enabled Debugger Support

By default, any debug exception inside an RTM region will cause atransactional abort and will redirect control flow to the fallbackinstruction address with architectural state recovered and bit 4 in EAXset. However, to allow software debuggers to intercept execution ondebug exceptions, the RTM architecture provides additional capability.

If bit 11 of DR7 and bit 15 of the IA32_DEBUGCTL_MSR are both 1, any RTMabort due to a debug exception (#DB) or breakpoint exception (#BP)causes execution to roll back and restart from the XBEGIN instructioninstead of the fallback address. In this scenario, the EAX register willalso be restored back to the point of the XBEGIN instruction.

Programming Considerations

Typical programmer-identified regions are expected to transactionallyexecute and commit successfully. However, Intel TSX does not provide anysuch guarantee. A transactional execution may abort for many reasons. Totake full advantage of the transactional capabilities, programmersshould follow certain guidelines to increase the probability of theirtransactional execution committing successfully.

This section discusses various events that may cause transactionalaborts. The architecture ensures that updates performed within atransaction that subsequently aborts execution will never becomevisible. Only committed transactional executions initiate an update tothe architectural state. Transactional aborts never cause functionalfailures and only affect performance.

Instruction Based Considerations

Programmers can use any instruction safely inside a transaction (HLE orRTM) and can use transactions at any privilege level. However, someinstructions will always abort the transactional execution and causeexecution to seamlessly and safely transition to a non-transactionalpath.

Intel TSX allows for most common instructions to be used insidetransactions without causing aborts. The following operations inside atransaction do not typically cause an abort:

-   -   Operations on the instruction pointer register, general purpose        registers (GPRs) and the status flags (CF, OF, SF, PF, AF, and        ZF); and    -   Operations on XMM and YMM registers and the MXCSR register.

However, programmers must be careful when intermixing SSE and AVXoperations inside a transactional region. Intermixing SSE instructionsaccessing XMM registers and AVX instructions accessing YMM registers maycause transactions to abort. Programmers may use REP/REPNE prefixedstring operations inside transactions. However, long strings may causeaborts. Further, the use of CLD and STD instructions may cause aborts ifthey change the value of the DF flag. However, if DF is 1, the STDinstruction will not cause an abort. Similarly, if DF is 0, then the CLDinstruction will not cause an abort.

Instructions not enumerated here as causing abort when used inside atransaction will typically not cause a transaction to abort (examplesinclude but are not limited to MFENCE, LFENCE, SFENCE, RDTSC, RDTSCP,etc.).

The following instructions will abort transactional execution on anyimplementation:

-   -   XABORT    -   CPUID    -   PAUSE

In addition, in some implementations, the following instructions mayalways cause transactional aborts. These instructions are not expectedto be commonly used inside typical transactional regions. However,programmers must not rely on these instructions to force a transactionalabort, since whether they cause transactional aborts is implementationdependent.

-   -   Operations on X87 and MMX architecture state. This includes all        MMX and X87 instructions, including the FXRSTOR and FXSAVE        instructions.    -   Update to non-status portion of EFLAGS: CLI, STI, POPFD, POPFQ,        CLTS.    -   Instructions that update segment registers, debug registers        and/or control registers: MOV to DS/ES/FS/GS/SS, POP        DS/ES/FS/GS/SS, LDS, LES, LFS, LGS, LSS, SWAPGS, WRFSBASE,        WRGSBASE, LGDT, SGDT, LIDT, SIDT, LLDT, SLDT, LTR, STR, Far        CALL, Far JMP, Far RET, IRET, MOV to DRx, MOV to        CR0/CR2/CR3/CR4/CR8 and LMSW.    -   Ring transitions: SYSENTER, SYSCALL, SYSEXIT, and SYSRET.    -   TLB and Cacheability control: CLFLUSH, INVD, WBINVD, INVLPG,        INVPCID, and memory instructions with a non-temporal hint        (MOVNTDQA, MOVNTDQ, MOVNTI, MOVNTPD, MOVNTPS, and MOVNTQ).    -   Processor state save: XSAVE, XSAVEOPT, and XRSTOR.    -   Interrupts: INTn, INTO.    -   IO: IN, INS, REP INS, OUT, OUTS, REP OUTS and their variants.    -   VMX: VMPTRLD, VMPTRST, VMCLEAR, VMREAD, VMWRITE, VMCALL,        VMLAUNCH, VMRESUME, VMXOFF, VMXON, INVEPT, and INVVPID.    -   SMX: GETSEC.    -   UD2, RSM, RDMSR, WRMSR, HLT, MONITOR, MWAIT, XSETBV, VZEROUPPER,        MASKMOVQ, and V/MASKMOVDQU.        Runtime Considerations

In addition to the instruction-based considerations, runtime events maycause transactional execution to abort. These may be due to data accesspatterns or micro-architectural implementation features. The followinglist is not a comprehensive discussion of all abort causes.

Any fault or trap in a transaction that must be exposed to software willbe suppressed. Transactional execution will abort and execution willtransition to a non-transactional execution, as if the fault or trap hadnever occurred. If an exception is not masked, then that un-maskedexception will result in a transactional abort and the state will appearas if the exception had never occurred.

Synchronous exception events (#DE, #OF, #NP, #SS, #GP, #BR, #UD, #AC,#XF, #PF, #NM, #TS, #MF, #DB, #BP/INT3) that occur during transactionalexecution may cause an execution not to commit transactionally, andrequire a non-transactional execution. These events are suppressed as ifthey had never occurred. With HLE, since the non-transactional code pathis identical to the transactional code path, these events will typicallyre-appear when the instruction that caused the exception is re-executednon-transactionally, causing the associated synchronous events to bedelivered appropriately in the non-transactional execution. Asynchronousevents (NMI, SMI, INTR, IPI, PMI, etc.) occurring during transactionalexecution may cause the transactional execution to abort and transitionto a non-transactional execution. The asynchronous events will be pendedand handled after the transactional abort is processed.

Transactions only support write-back cacheable memory type operations. Atransaction may always abort if the transaction includes operations onany other memory type. This includes instruction fetches to UC memorytype.

Memory accesses within a transactional region may require the processorto set the Accessed and Dirty flags of the referenced page table entry.The behavior of how the processor handles this is implementationspecific. Some implementations may allow the updates to these flags tobecome externally visible even if the transactional region subsequentlyaborts. Some Intel TSX implementations may choose to abort thetransactional execution if these flags need to be updated. Further, aprocessor's page-table walk may generate accesses to its owntransactionally written but uncommitted state. Some Intel TSXimplementations may choose to abort the execution of a transactionalregion in such situations. Regardless, the architecture ensures that, ifthe transactional region aborts, then the transactionally written statewill not be made architecturally visible through the behavior ofstructures such as TLBs.

Executing self-modifying code transactionally may also causetransactional aborts. Programmers must continue to follow the Intelrecommended guidelines for writing self-modifying and cross-modifyingcode even when employing HLE and RTM. While an implementation of RTM andHLE will typically provide sufficient resources for executing commontransactional regions, implementation constraints and excessive sizesfor transactional regions may cause a transactional execution to abortand transition to a non-transactional execution. The architectureprovides no guarantee of the amount of resources available to dotransactional execution and does not guarantee that a transactionalexecution will ever succeed.

Conflicting requests to a cache line accessed within a transactionalregion may prevent the transaction from executing successfully. Forexample, if logical processor P0 reads line A in a transactional regionand another logical processor P1 writes line A (either inside or outsidea transactional region) then logical processor P0 may abort if logicalprocessor P1's write interferes with processor P0's ability to executetransactionally.

Similarly, if P0 writes line A in a transactional region and P1 reads orwrites line A (either inside or outside a transactional region), then P0may abort if P1's access to line A interferes with P0's ability toexecute transactionally. In addition, other coherence traffic may attimes appear as conflicting requests and may cause aborts. While thesefalse conflicts may happen, they are expected to be uncommon. Theconflict resolution policy to determine whether P0 or P1 aborts in theabove scenarios is implementation specific.

Generic Transaction Execution Embodiments:

According to “ARCHITECTURES FOR TRANSACTIONAL MEMORY”, a dissertationsubmitted to the Department of Computer Science and the Committee onGraduate Studies of Stanford University in partial fulfillment of therequirements for the Degree of Doctor of Philosophy, by Austen McDonald,June 2009, incorporated by reference herein in its entirety,fundamentally, there are three mechanisms needed to implement an atomicand isolated transactional region: versioning, conflict detection, andcontention management.

To make a transactional code region appear atomic, all the modificationsperformed by that transactional code region must be stored and keptisolated from other transactions until commit time. The system does thisby implementing a versioning policy. Two versioning paradigms exist:eager and lazy. An eager versioning system stores newly generatedtransactional values in place and stores previous memory values on theside, in what is called an undo-log. A lazy versioning system stores newvalues temporarily in what is called a write buffer, copying them tomemory only on commit. In either system, the cache is used to optimizestorage of new versions.

To ensure serializability between transactions, conflicts must bedetected and resolved. The two systems, i.e., the eager and lazyversioning systems, detect conflicts by implementing a conflictdetection policy, either optimistic or pessimistic. An optimistic systemexecutes transactions in parallel, checking for conflicts only when atransaction commits. A pessimistic system checks for conflicts at eachload and store. Similar to versioning, conflict detection also uses thecache, marking each line as either part of the read-set, part of thewrite-set, or both. The two systems resolve conflicts by implementing acontention management policy. Many contention management policies exist,some are more appropriate for optimistic conflict detection and some aremore appropriate for pessimistic. Described below are some examplepolicies.

Since each transactional memory (TM) system needs both versioningdetection and conflict detection, these options give rise to fourdistinct TM designs: Eager-Pessimistic (EP), Eager-Optimistic (EO),Lazy-Pessimistic (LP), and Lazy-Optimistic (LO). Table 2 brieflydescribes all four distinct TM designs.

FIG. 1 depicts an example of a multicore TM environment. FIG. 1 showsmany TM-enabled CPUs (CPU1 114 a, CPU2 114 b, etc.) on one die 100,connected with an interconnect 122, under management of an interconnectcontrol 120 a, 120 b. Each CPU 114 a, 114 b (also known as a Processor)may have a split cache consisting of an Instruction Cache 116 a, 166 bfor caching instructions from memory to be executed and a Data Cache 118a, 118 b with TM support for caching data (operands) of memory locationsto be operated on by the CPU 114 a, 114 b. Each CPU 114 a, 114 b, 114 cand its associated caches are referenced as 112 a, 112 b, and 112 c. Inan implementation, caches of multiple dies 100 are interconnected tosupport cache coherency between the caches of the multiple dies 100. Inan implementation, a single cache, rather than the split cache isemployed holding both instructions and data. In implementations, the CPUcaches are one level of caching in a hierarchical cache structure. Forexample each die 100 may employ a shared cache 124 to be shared amongstall the CPUs on the die 100. In another implementation, each die mayhave access to a shared cache 124, shared amongst all the processors ofall the dies 100.

FIG. 1 also shows the details of an example transactional CPU 114 c,including additions to support TM. The transactional CPU (processor) 114c may include hardware for supporting Register Checkpoints 126 andspecial TM Registers 128. The transactional CPU cache may have the MESIbits 130, Tags 140 and Data 142 of a conventional cache but also, forexample, R bits 132 showing a line has been read by the CPU 114 c whileexecuting a transaction and W bits 138 showing a line has beenwritten-to by the CPU 114 c while executing a transaction.

A key detail for programmers in any TM system is how non-transactionalaccesses interact with transactions. By design, transactional accessesare screened from each other using the mechanisms above. However, theinteraction between a regular, non-transactional load with a transactioncontaining a new value for that address must still be considered. Inaddition, the interaction between a non-transactional store with atransaction that has read that address must also be explored. These areissues of the database concept isolation.

A TM system is said to implement strong isolation, sometimes calledstrong atomicity, when every non-transactional load and store acts likean atomic transaction. Therefore, non-transactional loads cannot seeuncommitted data and non-transactional stores cause atomicity violationsin any transactions that have read that address. A system where this isnot the case is said to implement weak isolation, sometimes called weakatomicity.

Strong isolation is often more desirable than weak isolation due to therelative ease of conceptualization and implementation of strongisolation. Additionally, if a programmer has forgotten to surround someshared memory references with transactions, causing bugs, then withstrong isolation, the programmer will often detect that oversight usinga simple debug interface because the programmer will see anon-transactional region causing atomicity violations. Also, programswritten in one model may work differently on another model.

Further, strong isolation is often easier to support in hardware TM thanweak isolation. With strong isolation, since the coherence protocolalready manages load and store communication between processors,transactions can detect non-transactional loads and stores and actappropriately. To implement strong isolation in software TransactionalMemory (TM), non-transactional code must be modified to include read-and write-barriers; potentially crippling performance. Although greateffort has been expended to remove many un-needed barriers, suchtechniques are often complex and performance is typically far lower thanthat of HTMs.

TABLE 2 Transactional Memory Design Space VERSIONING Lazy Eager CONFLICTOptimistic Storing updates in a write buffer; Not practical: waiting toupdate DETECTION detecting conflicts at commit time. memory until committime but detecting conflicts at access time guarantees wasted work andprovides no advantage Pessimistic Storing updates in a write buffer;Updating memory, keeping old detecting conflicts at access time. valuesin undo log; detecting conflicts at access time.

Table 2 illustrates the fundamental design space of transactional memory(versioning and conflict detection).

Eager-Pessimistic (EP)

This first TM design described below is known as Eager-Pessimistic. AnEP system stores its write-set “in place” (hence the name “eager”) and,to support rollback, stores the old values of overwritten lines in an“undo log”. Processors use the W 138 and R 132 cache bits to track readand write-sets and detect conflicts when receiving snooped loadrequests. Perhaps the most notable examples of EP systems in knownliterature are LogTM and UTM.

Beginning a transaction in an EP system is much like beginning atransaction in other systems: tm_begin( ) takes a register checkpoint,and initializes any status registers. An EP system also requiresinitializing the undo log, the details of which are dependent on the logformat, but often involve initializing a log base pointer to a region ofpre-allocated, thread-private memory, and clearing a log boundsregister.

Versioning: In EP, due to the way eager versioning is designed tofunction, the MESI 130 state transitions (cache line indicatorscorresponding to Modified, Exclusive, Shared, and Invalid code states)are left mostly unchanged. Outside of a transaction, the MESI 130 statetransitions are left completely unchanged. When reading a line inside atransaction, the standard coherence transitions apply (S (Shared)→S, I(Invalid)→S, or I→E (Exclusive)), issuing a load miss as needed, but theR 132 bit is also set. Likewise, writing a line applies the standardtransitions (S→M, E→I, I→M), issuing a miss as needed, but also sets theW 138 (Written) bit. The first time a line is written, the old versionof the entire line is loaded then written to the undo log to preserve itin case the current transaction aborts. The newly written data is thenstored “in-place,” over the old data.

Conflict Detection: Pessimistic conflict detection uses coherencemessages exchanged on misses, or upgrades, to look for conflicts betweentransactions. When a read miss occurs within a transaction, otherprocessors receive a load request; but they ignore the request if theydo not have the needed line. If the other processors have the neededline non-speculatively or have the line R 132 (Read), they downgradethat line to S, and in certain cases issue a cache-to-cache transfer ifthey have the line in MESI's 130 M or E state. However, if the cache hasthe line W 138, then a conflict is detected between the two transactionsand additional action(s) must be taken.

Similarly, when a transaction seeks to upgrade a line from shared tomodified (on a first write), the transaction issues an exclusive loadrequest, which is also used to detect conflicts. If a receiving cachehas the line non-speculatively, then the line is invalidated, and incertain cases a cache-to-cache transfer (M or E states) is issued. But,if the line is R 132 or W 138, a conflict is detected.

Validation: Because conflict detection is performed on every load, atransaction always has exclusive access to its own write-set. Therefore,validation does not require any additional work.

Commit: Since eager versioning stores the new version of data items inplace, the commit process simply clears the W 138 and R 132 bits anddiscards the undo log.

Abort: When a transaction rolls back, the original version of each cacheline in the undo log must be restored, a process called “unrolling” or“applying” the log. This is done during tm_discard( ) and must be atomicwith regard to other transactions. Specifically, the write-set muststill be used to detect conflicts: this transaction has the only correctversion of lines in its undo log, and requesting transactions must waitfor the correct version to be restored from that log. Such a log can beapplied using a hardware state machine or software abort handler.

Eager-Pessimistic has the characteristics of: Commit is simple and sinceit is in-place, very fast. Similarly, validation is a no-op. Pessimisticconflict detection detects conflicts early, thereby reducing the numberof “doomed” transactions. For example, if two transactions are involvedin a Write-After-Read dependency, then that dependency is detectedimmediately in pessimistic conflict detection. However, in optimisticconflict detection such conflicts are not detected until the writercommits.

Eager-Pessimistic also has the characteristics of: As described above,the first time a cache line is written, the old value must be written tothe log, incurring extra cache accesses. Aborts are expensive as theyrequire undoing the log. For each cache line in the log, a load must beissued, perhaps going as far as main memory before continuing to thenext line. Pessimistic conflict detection also prevents certainserializable schedules from existing.

Additionally, because conflicts are handled as they occur, there is apotential for livelock and careful contention management mechanisms mustbe employed to guarantee forward progress.

Lazy-Optimistic (LO)

Another popular TM design is Lazy-Optimistic (LO), which stores itswrite-set in a “write buffer” or “redo log” and detects conflicts atcommit time (still using the R 132 and W 138 bits).

Versioning: Just as in the EP system, the MESI protocol of the LO designis enforced outside of the transactions. Once inside a transaction,reading a line incurs the standard MESI transitions but also sets the R132 bit. Likewise, writing a line sets the W 138 bit of the line, buthandling the MESI transitions of the LO design is different from that ofthe EP design. First, with lazy versioning, the new versions of writtendata are stored in the cache hierarchy until commit while othertransactions have access to old versions available in memory or othercaches. To make available the old versions, dirty lines (M lines) mustbe evicted when first written by a transaction. Second, no upgrademisses are needed because of the optimistic conflict detection feature:if a transaction has a line in the S state, it can simply write to itand upgrade that line to an M state without communicating the changeswith other transactions because conflict detection is done at committime.

Conflict Detection and Validation: To validate a transaction and detectconflicts, LO communicates the addresses of speculatively modified linesto other transactions only when it is preparing to commit. Onvalidation, the processor sends one, potentially large, network packetcontaining all the addresses in the write-set. Data is not sent, butleft in the cache of the committer and marked dirty (M). To build thispacket without searching the cache for lines marked W, a simple bitvector is used, called a “store buffer,” with one bit per cache line totrack these speculatively modified lines. Other transactions use thisaddress packet to detect conflicts: if an address is found in the cacheand the R 132 and/or W 138 bits are set, then a conflict is initiated.If the line is found but neither R 132 nor W 138 is set, then the lineis simply invalidated, which is similar to processing an exclusive load.

To support transaction atomicity, these address packets must be handledatomically, i.e., no two address packets may exist at once with the sameaddresses. In an LO system, this can be achieved by simply acquiring aglobal commit token before sending the address packet. However, atwo-phase commit scheme could be employed by first sending out theaddress packet, collecting responses, enforcing an ordering protocol(perhaps oldest transaction first), and committing once all responsesare satisfactory.

Commit: Once validation has occurred, commit needs no special treatment:simply clear W 138 and R 132 bits and the store buffer. Thetransaction's writes are already marked dirty in the cache and othercaches' copies of these lines have been invalidated via the addresspacket. Other processors can then access the committed data through theregular coherence protocol.

Abort: Rollback is equally easy: because the write-set is containedwithin the local caches, these lines can be invalidated, then clear W138 and R 132 bits and the store buffer. The store buffer allows W linesto be found to invalidate without the need to search the cache.

Lazy-Optimistic has the characteristics of: Aborts are very fast,requiring no additional loads or stores and making only local changes.More serializable schedules can exist than found in EP, which allows anLO system to more aggressively speculate that transactions areindependent, which can yield higher performance. Finally, the latedetection of conflicts can increase the likelihood of forward progress.

Lazy-Optimistic also has the characteristics of: Validation takes globalcommunication time proportional to size of write set. Doomedtransactions can waste work since conflicts are detected only at committime.

Lazy-Pessimistic (LP)

Lazy-Pessimistic (LP) represents a third TM design option, sittingsomewhere between EP and LO: storing newly written lines in a writebuffer but detecting conflicts on a per access basis.

Versioning: Versioning is similar but not identical to that of LO:reading a line sets its R bit 132, writing a line sets its W bit 138,and a store buffer is used to track W lines in the cache. Also, dirty(M) lines must be evicted when first written by a transaction, just asin LO. However, since conflict detection is pessimistic, load exclusivesmust be performed when upgrading a transactional line from I, S→M, whichis unlike LO.

Conflict Detection: LP's conflict detection operates the same as EP's:using coherence messages to look for conflicts between transactions.

Validation: Like in EP, pessimistic conflict detection ensures that atany point, a running transaction has no conflicts with any other runningtransaction, so validation is a no-op.

Commit: Commit needs no special treatment: simply clear W 138 and R 132bits and the store buffer, like in LO.

Abort: Rollback is also like that of LO: simply invalidate the write-setusing the store buffer and clear the W and R bits and the store buffer.

Eager-Optimistic (EO)

The LP has the characteristics of: Like LO, aborts are very fast. LikeEP, the use of pessimistic conflict detection reduces the number of“doomed” transactions. Like EP, some serializable schedules are notallowed and conflict detection must be performed on each cache miss.

The final combination of versioning and conflict detection isEager-Optimistic (EO). EO may be a less than optimal choice for HTMsystems: since new transactional versions are written in-place, othertransactions have no choice but to notice conflicts as they occur (i.e.,as cache misses occur). But since EO waits until commit time to detectconflicts, those transactions become “zombies,” continuing to execute,wasting resources, yet are “doomed” to abort.

EO has proven to be useful in STMs and is implemented by Bartok-STM andMcRT. A lazy versioning STM needs to check its write buffer on each readto ensure that it is reading the most recent value. Since the writebuffer is not a hardware structure, this is expensive, hence thepreference for write-in-place eager versioning. Additionally, sincechecking for conflicts is also expensive in an STM, optimistic conflictdetection offers the advantage of performing this operation in bulk.

Contention Management

How a transaction rolls back once the system has decided to abort thattransaction has been described above, but, since a conflict involves twotransactions, the topics of which transaction should abort, how thatabort should be initiated, and when should the aborted transaction beretried need to be explored. These are topics that are addressed byContention Management (CM), a key component of transactional memory.Described below are policies regarding how the systems initiate abortsand the various established methods of managing which transactionsshould abort in a conflict.

Contention Management Policies

A Contention Management (CM) Policy is a mechanism that determines whichtransaction involved in a conflict should abort and when the abortedtransaction should be retried. For example, it is often the case thatretrying an aborted transaction immediately does not lead to the bestperformance. Conversely, employing a back-off mechanism, which delaysthe retrying of an aborted transaction, can yield better performance.STMs first grappled with finding the best contention management policiesand many of the policies outlined below were originally developed forSTMs.

CM Policies draw on a number of measures to make decisions, includingages of the transactions, size of read- and write-sets, the number ofprevious aborts, etc. The combinations of measures to make suchdecisions are endless, but certain combinations are described below,roughly in order of increasing complexity.

To establish some nomenclature, first note that in a conflict there aretwo sides: the attacker and the defender. The attacker is thetransaction requesting access to a shared memory location. Inpessimistic conflict detection, the attacker is the transaction issuingthe load or load exclusive. In optimistic, the attacker is thetransaction attempting to validate. The defender in both cases is thetransaction receiving the attacker's request.

An Aggressive CM Policy immediately and always retries either theattacker or the defender. In LO, Aggressive means that the attackeralways wins, and so Aggressive is sometimes called committer wins. Sucha policy was used for the earliest LO systems. In the case of EP,Aggressive can be either defender wins or attacker wins.

Restarting a conflicting transaction that will immediately experienceanother conflict is bound to waste work—namely interconnect bandwidthrefilling cache misses. A Polite CM Policy employs exponential backoff(but linear could also be used) before restarting conflicts. To preventstarvation, a situation where a process does not have resourcesallocated to it by the scheduler, the exponential backoff greatlyincreases the odds of transaction success after some n retries.

Another approach to conflict resolution is to randomly abort theattacker or defender (a policy called Randomized). Such a policy may becombined with a randomized backoff scheme to avoid unneeded contention.

However, making random choices, when selecting a transaction to abort,can result in aborting transactions that have completed “a lot of work”,which can waste resources. To avoid such waste, the amount of workcompleted on the transaction can be taken into account when determiningwhich transaction to abort. One measure of work could be a transaction'sage. Other methods include Oldest, Bulk TM, Size Matters, Karma, andPolka. Oldest is a simple timestamp method that aborts the youngertransaction in a conflict. Bulk TM uses this scheme. Size Matters islike Oldest but instead of transaction age, the number of read/writtenwords is used as the priority, reverting to Oldest after a fixed numberof aborts. Karma is similar, using the size of the write-set aspriority. Rollback then proceeds after backing off a fixed amount oftime. Aborted transactions keep their priorities after being aborted(hence the name Karma). Polka works like Karma but instead of backingoff a predefined amount of time, it backs off exponentially more eachtime.

Since aborting wastes work, it is logical to argue that stalling anattacker until the defender has finished their transaction would lead tobetter performance. Unfortunately, such a simple scheme easily leads todeadlock.

Deadlock avoidance techniques can be used to solve this problem. Greedyuses two rules to avoid deadlock. The first rule is, if a firsttransaction, T1, has lower priority than a second transaction, T0, or ifT1 is waiting for another transaction, then T1 aborts when conflictingwith T0. The second rule is, if T1 has higher priority than T0 and isnot waiting, then T0 waits until T1 commits, aborts, or starts waiting(in which case the first rule is applied). Greedy provides someguarantees about time bounds for executing a set of transactions. One EPdesign (LogTM) uses a CM policy similar to Greedy to achieve stallingwith conservative deadlock avoidance.

Example MESI coherency rules provide for four possible states in which acache line of a multiprocessor cache system may reside, M, E, S, and I,defined as follows:

Modified (M): The cache line is present only in the current cache, andis dirty; it has been modified from the value in main memory. The cacheis required to write the data back to main memory at some time in thefuture, before permitting any other read of the (no longer valid) mainmemory state. The write-back changes the line to the Exclusive state.

Exclusive (E): The cache line is present only in the current cache, butis clean; it matches main memory. It may be changed to the Shared stateat any time, in response to a read request. Alternatively, it may bechanged to the Modified state when writing to it.

Shared (S): Indicates that this cache line may be stored in other cachesof the machine and is “clean”; it matches the main memory. The line maybe discarded (changed to the Invalid state) at any time.

Invalid (I): Indicates that this cache line is invalid (unused).

TM coherency status indicators (R 132, W 138) may be provided for eachcache line, in addition to, or encoded in the MESI coherency bits. An R132 indicator indicates the current transaction has read from the dataof the cache line, and a W 138 indicator indicates the currenttransaction has written to the data of the cache line.

In another aspect of TM design, a system is designed using transactionalstore buffers. U.S. Pat. No. 6,349,361 titled “Methods and Apparatus forReordering and Renaming Memory References in a Multiprocessor ComputerSystem,” filed Mar. 31, 2000 and incorporated by reference herein in itsentirety, teaches a method for reordering and renaming memory referencesin a multiprocessor computer system having at least a first and a secondprocessor. The first processor has a first private cache and a firstbuffer, and the second processor has a second private cache and a secondbuffer. The method includes the steps of, for each of a plurality ofgated store requests received by the first processor to store a datum,exclusively acquiring a cache line that contains the datum by the firstprivate cache, and storing the datum in the first buffer. Upon the firstbuffer receiving a load request from the first processor to load aparticular datum, the particular datum is provided to the firstprocessor from among the data stored in the first buffer based on anin-order sequence of load and store operations. Upon the first cachereceiving a load request from the second cache for a given datum, anerror condition is indicated and a current state of at least one of theprocessors is reset to an earlier state when the load request for thegiven datum corresponds to the data stored in the first buffer.

The main implementation components of one such transactional memoryfacility are a transaction-backup register file for holdingpre-transaction GR (general register) content, a cache directory totrack the cache lines accessed during the transaction, a store cache tobuffer stores until the transaction ends, and firmware routines toperform various complex functions. In this section a detailedimplementation is described.

IBM zEnterprise EC12 Enterprise Server Embodiment

The IBM zEnterprise EC12 enterprise server introduces transactionalexecution (TX) in transactional memory, and is described in part in apaper, “Transactional Memory Architecture and Implementation for IBMSystem z” of Proceedings Pages 25-36 presented at MICRO-45, 1-5 Dec.2012, Vancouver, British Columbia, Canada, available from IEEE ComputerSociety Conference Publishing Services (CPS), which is incorporated byreference herein in its entirety.

Table 3 shows an example transaction. Transactions started with TBEGINare not assured to ever successfully complete with TEND, since they canexperience an aborting condition at every attempted execution, e.g., dueto repeating conflicts with other CPUs. This requires that the programsupport a fallback path to perform the same operationnon-transactionally, e.g., by using traditional locking schemes. Thisputs significant burden on the programming and software verificationteams, especially where the fallback path is not automatically generatedby a reliable compiler.

TABLE 3 Example Transaction Code LHI R0, 0 *initialize retry count = 0loop TBEGIN *begin transaction JNZ abort *go to abort code if CC1 = 0 LTR1, lock *load and test the fallback lock JNZ lckbzy *branch if lockbusy . . . perform operation . . . TEND *end transaction . . .  . . .  .. .  . . . lckbzy TABORT *abort if lock busy; this *resumes after TBEGINabort JO fallback *no retry if CC = 3 AHI R0, 1 *increment retry countCIJNL R0, 6, fallback *give up after 6 attempts PPA R0, TX *random delaybased on retry count . . . potentially wait for lock to become free . .. J loop *jump back to retry fallback OBTAIN lock *using Compare&Swap .. . perform operation . . . RELEASE lock . . .  . . .  . . .  . . .

The requirement of providing a fallback path for aborted TransactionExecution (TX) transactions can be onerous. Many transactions operatingon shared data structures are expected to be short, touch only a fewdistinct memory locations, and use simple instructions only. For thosetransactions, the IBM zEnterprise EC12 introduces the concept ofconstrained transactions; under normal conditions, the CPU 114 c assuresthat constrained transactions eventually end successfully, albeitwithout giving a strict limit on the number of necessary retries. Aconstrained transaction starts with a TBEGINC instruction and ends witha regular TEND. Implementing a task as a constrained or non-constrainedtransaction typically results in very comparable performance, butconstrained transactions simplify software development by removing theneed for a fallback path. IBM's Transactional Execution architecture isfurther described in z/Architecture, Principles of Operation, TenthEdition, SA22-7832-09 published September 2012 from IBM, incorporated byreference herein in its entirety.

A constrained transaction starts with the TBEGINC instruction. Atransaction initiated with TBEGINC must follow a list of programmingconstraints; otherwise the program takes a non-filterableconstraint-violation interruption. Exemplary constraints may include,but not be limited to: the transaction can execute a maximum of 32instructions, all instruction text must be within 256 consecutive bytesof memory; the transaction contains only forward-pointing relativebranches (i.e., no loops or subroutine calls); the transaction canaccess a maximum of 4 aligned octowords (an octoword is 32 bytes) ofmemory; and restriction of the instruction-set to exclude complexinstructions like decimal or floating-point operations. The constraintsare chosen such that many common operations like doubly linkedlist-insert/delete operations can be performed, including the verypowerful concept of atomic compare-and-swap targeting up to 4 alignedoctowords. At the same time, the constraints were chosen conservativelysuch that future CPU implementations can assure transaction successwithout needing to adjust the constraints, since that would otherwiselead to software incompatibility.

TBEGINC mostly behaves like XBEGIN in TSX or TBEGIN on IBM's zEC12servers, except that the floating-point register (FPR) control and theprogram interruption filtering fields do not exist and the controls areconsidered to be zero. On a transaction abort, the instruction addressis set back directly to the TBEGINC instead of to the instruction after,reflecting the immediate retry and absence of an abort path forconstrained transactions.

Nested transactions are not allowed within constrained transactions, butif a TBEGINC occurs within a non-constrained transaction it is treatedas opening a new non-constrained nesting level just like TBEGIN would.This can occur, e.g., if a non-constrained transaction calls asubroutine that uses a constrained transaction internally.

Since interruption filtering is implicitly off, all exceptions during aconstrained transaction lead to an interruption into the operatingsystem (OS). Eventual successful finishing of the transaction relies onthe capability of the OS to page-in the at most 4 pages touched by anyconstrained transaction. The OS must also ensure time-slices long enoughto allow the transaction to complete.

TABLE 4 Transaction Code Example TBEGINC *begin constrained transaction. . . perform operation . . . TEND *end transaction

Table 4 shows the constrained-transactional implementation of the codein Table 3, assuming that the constrained transactions do not interactwith other locking-based code. No lock testing is shown therefore, butcould be added if constrained transactions and lock-based code weremixed.

When failure occurs repeatedly, software emulation is performed usingmillicode as part of system firmware. Advantageously, constrainedtransactions have desirable properties because of the burden removedfrom programmers.

With reference to FIG. 2, the IBM zEnterprise EC12 processor introducedthe transactional execution facility. The processor can decode 3instructions per clock cycle; simple instructions are dispatched assingle micro-ops, and more complex instructions are cracked intomultiple micro-ops. The micro-ops (Uops 232 b) are written into aunified issue queue 216, from where they can be issued out-of-order. Upto two fixed-point, one floating-point, two load/store, and two branchinstructions can execute every cycle. A Global Completion Table (GCT)232 holds every micro-op and a transaction nesting depth (TND) 232 a.The GCT 232 is written in-order at decode time, tracks the executionstatus of each micro-op 232 b, and completes instructions when allmicro-ops 232 b of the oldest instruction group have successfullyexecuted.

The level 1 (L1) data cache 240 is a 96 KB (kilo-byte) 6-way associativecache with 256 byte cache-lines and 4 cycle use latency, coupled to aprivate 1 MB (mega-byte) 8-way associative 2nd-level (L2) data cache 268with 7 cycles use-latency penalty for L1 240 misses. L1 240 cache is thecache closest to a processor and Ln cache is a cache at the nth level ofcaching. Both L1 240 and L2 268 caches are store-through. Six cores oneach central processor (CP) chip share a 48 MB 3rd-level store-in cache,and six CP chips are connected to an off-chip 384 MB 4th-level cache,packaged together on a glass ceramic multi-chip module (MCM). Up to 4multi-chip modules (MCMs) can be connected to a coherent symmetricmulti-processor (SMP) system with up to 144 cores (not all cores areavailable to run customer workload).

Coherency is managed with a variant of the MESI protocol. Cache-linescan be owned read-only (shared) or exclusive; the L1 240 and L2 268 arestore-through and thus do not contain dirty lines. The L3 272 and L4caches (not shown) are store-in and track dirty states. Each cache isinclusive of all its connected lower level caches.

Coherency requests are called “cross interrogates” (XI) and are senthierarchically from higher level to lower-level caches, and between theL4s. When one core misses the L1 240 and L2 268 and requests the cacheline from its local L3 272, the L3 272 checks whether it owns the line,and if necessary sends an XI to the currently owning L2 268/L1 240 underthat L3 272 to ensure coherency, before it returns the cache line to therequestor. If the request also misses the L3 272, the L3 272 sends arequest to the L4 (not shown), which enforces coherency by sending XIsto all necessary L3s under that L4, and to the neighboring L4s. Then theL4 responds to the requesting L3 which forwards the response to the L2268/L1 240.

Note that due to the inclusivity rule of the cache hierarchy, sometimescache lines are XI'ed from lower-level caches due to evictions onhigher-level caches caused by associativity overflows from requests toother cache lines. These XIs can be called “LRU XIs”, where LRU standsfor least recently used.

Making reference to yet another type of XI requests, Demote-XIstransition cache-ownership from exclusive into read-only state, andExclusive-XIs transition cache ownership from exclusive into invalidstate. Demote-XIs and Exclusive-XIs need a response back to the XIsender. The target cache can “accept” the XI, or send a “reject”response if it first needs to evict dirty data before accepting the XI.The L1 240/L2 268 caches are store through, but may reject demote-XIsand exclusive XIs if they have stores in their store queues that need tobe sent to L3 before downgrading the exclusive state. A rejected XI willbe repeated by the sender. Read-only-XIs are sent to caches that own theline read-only; no response is needed for such XIs since they cannot berejected. The details of the SMP protocol are similar to those describedfor the IBM z10 by P. Mak, C. Walters, and G. Strait, in “IBM System z10processor cache subsystem microarchitecture”, IBM Journal of Researchand Development, Vol 53:1, 2009, which is incorporated by referenceherein in its entirety.

Transactional Instruction Execution

FIG. 2 depicts example components of an example CPU environment 112,including a CPU 114 c and caches/components with which it interacts(such as those depicted in FIG. 1). The instruction decode unit 208(IDU) keeps track of the current transaction nesting depth 212 (TND).When the IDU 208 receives a TBEGIN instruction, the nesting depth 212 isincremented, and conversely decremented on TEND instructions. Thenesting depth 212 is written into the GCT 232 for every dispatchedinstruction. When a TBEGIN or TEND is decoded on a speculative path thatlater gets flushed, the IDU's 208 nesting depth 212 is refreshed fromthe youngest GCT 232 entry that is not flushed. The transactional stateis also written into the issue queue 216 for consumption by theexecution units, mostly by the Load/Store Unit (LSU) 280, which also hasan effective address calculator 236 is included in the LSU 280. TheTBEGIN instruction may specify a transaction diagnostic block (TDB) forrecording status information, should the transaction abort beforereaching a TEND instruction.

Similar to the nesting depth, the IDU 208/GCT 232 collaboratively trackthe access register/floating-point register (AR/FPR) modification masksthrough the transaction nest; the IDU 208 can place an abort requestinto the GCT 232 when an AR/FPR-modifying instruction is decoded and themodification mask blocks that. When the instruction becomesnext-to-complete, completion is blocked and the transaction aborts.Other restricted instructions are handled similarly, including TBEGIN ifdecoded while in a constrained transaction, or exceeding the maximumnesting depth.

An outermost TBEGIN is cracked into multiple micro-ops depending on theGR-Save-Mask; each micro-op 232 b (including, for example uop 0, uop 1,and uop2) will be executed by one of the two fixed point units (FXUs)220 to save a pair of GRs 228 into a special transaction-backup registerfile 224, that is used to later restore the GR 228 content in case of atransaction abort. Also the TBEGIN spawns micro-ops 232 b to perform anaccessibility test for the TDB if one is specified; the address is savedin a special purpose register for later usage in the abort case. At thedecoding of an outermost TBEGIN, the instruction address and theinstruction text of the TBEGIN are also saved in special purposeregisters for a potential abort processing later on.

TEND and NTSTG are single micro-op 232 b instructions; NTSTG(non-transactional store) is handled like a normal store except that itis marked as non-transactional in the issue queue 216 so that the LSU280 can treat it appropriately. TEND is a no-op at execution time, theending of the transaction is performed when TEND completes.

As mentioned, instructions that are within a transaction are marked assuch in the issue queue 216, but otherwise execute mostly unchanged; theLSU 280 performs isolation tracking as described in the next section.

Since decoding is in-order, and since the IDU 208 keeps track of thecurrent transactional state and writes it into the issue queue 216 alongwith every instruction from the transaction, execution of TBEGIN, TEND,and instructions before, within, and after the transaction can beperformed out-of order. It is even possible (though unlikely) that TENDis executed first, then the entire transaction, and lastly the TBEGINexecutes. Program order is restored through the GCT 232 at completiontime. The length of transactions is not limited by the size of the GCT232, since general purpose registers (GRs) 228 can be restored from thebackup register file 224.

During execution, the program event recording (PER) events are filteredbased on the Event Suppression Control, and a PER TEND event is detectedif enabled. Similarly, while in transactional mode, a pseudo-randomgenerator may be causing the random aborts as enabled by the TransactionDiagnostics Control.

Tracking for Transactional Isolation

The Load/Store Unit 280 tracks cache lines that were accessed duringtransactional execution, and triggers an abort if an XI from another CPU(or an LRU-XI) conflicts with the footprint. If the conflicting XI is anexclusive or demote XI, the LSU 280 rejects the XI back to the L3 272 inthe hope of finishing the transaction before the L3 272 repeats the XI.This “stiff-arming” is very efficient in highly contended transactions.In order to prevent hangs when two CPUs stiff-arm each other, aXI-reject counter is implemented, which triggers a transaction abortwhen a threshold is met.

The L1 cache directory 240 is traditionally implemented with staticrandom access memories (SRAMs). For the transactional memoryimplementation, the valid bits 244 (64 rows×6 ways) of the directoryhave been moved into normal logic latches, and are supplemented with twomore bits per cache line: the TX-read 248 and TX-dirty 252 bits.

The TX-read 248 bits are reset when a new outermost TBEGIN is decoded(which is interlocked against a prior still pending transaction). TheTX-read 248 bit is set at execution time by every load instruction thatis marked “transactional” in the issue queue. Note that this can lead toover-marking if speculative loads are executed, for example on amispredicted branch path. The alternative of setting the TX-read 248 bitat load completion time was too expensive for silicon area, sincemultiple loads can complete at the same time, requiring many read-portson the load-queue.

Stores execute the same way as in non-transactional mode, but atransaction mark is placed in the store queue (STQ) 260 entry of thestore instruction. At write-back time, when the data from the STQ 260 iswritten into the L1 240, the TX-dirty bit 252 in the L1-directory 256 isset for the written cache line. Store write-back into the L1 240 occursonly after the store instruction has completed, and at most one store iswritten back per cycle. Before completion and write-back, loads canaccess the data from the STQ 260 by means of store-forwarding; afterwrite-back, the CPU 114 c (FIG. 1) can access the speculatively updateddata in the L1 240. If the transaction ends successfully, the TX-dirtybits 252 of all cache-lines are cleared, and also the TX-marks of notyet written stores are cleared in the STQ 260, effectively turning thepending stores into normal stores.

On a transaction abort, all pending transactional stores are invalidatedfrom the STQ 260, even those already completed. All cache lines thatwere modified by the transaction in the L1 240, that is, have theTX-dirty bit 252 on, have their valid bits turned off, effectivelyremoving them from the L1 240 cache instantaneously.

The architecture requires that before completing a new instruction, theisolation of the transaction read- and write-set is maintained. Thisisolation is ensured by stalling instruction completion at appropriatetimes when XIs are pending; speculative out-of order execution isallowed, optimistically assuming that the pending XIs are to differentaddresses and not actually cause a transaction conflict. This designfits very naturally with the XI-vs-completion interlocks that areimplemented on prior systems to ensure the strong memory ordering thatthe architecture requires.

When the L1 240 receives an XI, L1 240 accesses the directory to checkvalidity of the XI'ed address in the L1 240, and if the TX-read bit 248is active on the XI'ed line and the XI is not rejected, the LSU 280triggers an abort. When a cache line with active TX-read bit 248 isLRU'ed from the L1 240, a special LRU-extension vector remembers foreach of the 64 rows of the L1 240 that a TX-read line existed on thatrow. Since no precise address tracking exists for the LRU extensions,any non-rejected XI that hits a valid extension row the LSU 280 triggersan abort. Providing the LRU-extension effectively increases the readfootprint capability from the L1-size to the L2-size and associativity,provided no conflicts with other CPUs 114 c (FIG. 1) against thenon-precise LRU-extension tracking causes aborts.

The store footprint is limited by the store cache size (the store cacheis discussed in more detail below) and thus implicitly by the L2 268size and associativity. No LRU-extension action needs to be performedwhen a TX-dirty 252 cache line is LRU'ed from the L1 240.

Store Cache

In prior systems, since the L1 240 and L2 268 are store-through caches,every store instruction causes an L3 272 store access; with now 6 coresper L3 272 and further improved performance of each core, the store ratefor the L3 272 (and to a lesser extent for the L2 268) becomesproblematic for certain workloads. In order to avoid store queuingdelays, a gathering store cache 264 had to be added, that combinesstores to neighboring addresses before sending them to the L3 272.

For transactional memory performance, it is acceptable to invalidateevery TX-dirty 252 cache line from the L1 240 on transaction aborts,because the L2 268 cache is very close (7 cycles L1 240 miss penalty) tobring back the clean lines. However, it would be unacceptable forperformance (and silicon area for tracking) to have transactional storeswrite the L2 268 before the transaction ends and then invalidate alldirty L2 268 cache lines on abort (or even worse on the shared L3 272).

The two problems of store bandwidth and transactional memory storehandling can both be addressed with the gathering store cache 264. Thecache 232 is a circular queue of 64 entries, each entry holding 128bytes of data with byte-precise valid bits. In non-transactionaloperation, when a store is received from the LSU 280, the store cachechecks whether an entry exists for the same address, and if so gathersthe new store into the existing entry. If no entry exists, a new entryis written into the queue, and if the number of free entries falls undera threshold, the oldest entries are written back to the L2 268 and L3272 caches.

When a new outermost transaction begins, all existing entries in thestore cache are marked closed so that no new stores can be gathered intothem, and eviction of those entries to L2 268 and L3 272 is started.From that point on, the transactional stores coming out of the LSU 280STQ 260 allocate new entries, or gather into existing transactionalentries. The write-back of those stores into L2 268 and L3 272 isblocked, until the transaction ends successfully; at that pointsubsequent (post-transaction) stores can continue to gather intoexisting entries, until the next transaction closes those entries again.

The store cache is queried on every exclusive or demote XI, and causesan XI reject if the XI compares to any active entry. If the core is notcompleting further instructions while continuously rejecting XIs, thetransaction is aborted at a certain threshold to avoid hangs.

The LSU 280 requests a transaction abort when the store cache overflows.The LSU 280 detects this condition when it tries to send a new storethat cannot merge into an existing entry, and the entire store cache isfilled with stores from the current transaction. The store cache ismanaged as a subset of the L2 268: while transactionally dirty lines canbe evicted from the L1 240, they have to stay resident in the L2 268throughout the transaction. The maximum store footprint is thus limitedto the store cache size of 64×128 bytes, and it is also limited by theassociativity of the L2 268. Since the L2 268 is 8-way associative andhas 512 rows, it is typically large enough to not cause transactionaborts.

If a transaction aborts, the store cache is notified and all entriesholding transactional data are invalidated. The store cache also has amark per doubleword (8 bytes) whether the entry was written by a NTSTGinstruction—those doublewords stay valid across transaction aborts.

Millicode-Implemented Functions

Traditionally, IBM mainframe server processors contain a layer offirmware called millicode which performs complex functions like certainCISC instruction executions, interruption handling, systemsynchronization, and RAS. Millicode includes machine dependentinstructions as well as instructions of the instruction set architecture(ISA) that are fetched and executed from memory similarly toinstructions of application programs and the operating system (OS).Firmware resides in a restricted area of main memory that customerprograms cannot access. When hardware detects a situation that needs toinvoke millicode, the instruction fetching unit 204 switches into“millicode mode” and starts fetching at the appropriate location in themillicode memory area. Millicode may be fetched and executed in the sameway as instructions of the instruction set architecture (ISA), and mayinclude ISA instructions.

For transactional memory, millicode is involved in various complexsituations. Every transaction abort invokes a dedicated millicodesub-routine to perform the necessary abort steps. The transaction-abortmillicode starts by reading special-purpose registers (SPRs) holding thehardware internal abort reason, potential exception reasons, and theaborted instruction address, which millicode then uses to store a TDB ifone is specified. The TBEGIN instruction text is loaded from an SPR toobtain the GR-save-mask, which is needed for millicode to know which GRs238 to restore.

The CPU 114 c (FIG. 1) supports a special millicode-only instruction toread out the backup-GRs 224 and copy them into the main GRs 228. TheTBEGIN instruction address is also loaded from an SPR to set the newinstruction address in the PSW to continue execution after the TBEGINonce the millicode abort sub-routine finishes. That PSW may later besaved as program-old PSW in case the abort is caused by a non-filteredprogram interruption.

The TABORT instruction may be millicode implemented; when the IDU 208decodes TABORT, it instructs the instruction fetch unit to branch intoTABORT's millicode, from which millicode branches into the common abortsub-routine.

The Extract Transaction Nesting Depth (ETND) instruction may also bemillicoded, since it is not performance critical; millicode loads thecurrent nesting depth out of a special hardware register and places itinto a GR 228. The PPA instruction is millicoded; it performs theoptimal delay based on the current abort count provided by software asan operand to PPA, and also based on other hardware internal state.

For constrained transactions, millicode may keep track of the number ofaborts. The counter is reset to 0 on successful TEND completion, or ifan interruption into the OS occurs (since it is not known if or when theOS will return to the program). Depending on the current abort count,millicode can invoke certain mechanisms to improve the chance of successfor the subsequent transaction retry. The mechanisms involve, forexample, successively increasing random delays between retries, andreducing the amount of speculative execution to avoid encounteringaborts caused by speculative accesses to data that the transaction isnot actually using. As a last resort, millicode can broadcast to otherCPUs 114 c (FIG. 1) to stop all conflicting work, retry the localtransaction, before releasing the other CPUs 114 c to continue normalprocessing. Multiple CPUs 114 c must be coordinated to not causedeadlocks, so some serialization between millicode instances ondifferent CPUs 114 c is required.

U.S. Pat. No. 5,802,572 titled “Write-back Cache having Sub-line SizeCoherency Granularity and Method for Maintaining Coherency within aWrite-back Cache” filed 1996-03-15, incorporated herein by reference inits entirety, teaches a write-back cache memory and method formaintaining coherency within a write-back cache memory. The write-backcache memory includes a number of cache lines for storing dataassociated with addresses within an associated memory. Each of the cachelines comprises multiple byte sets. The write-back cache memory alsoincludes coherency indicia for identifying each byte set among themultiple byte sets within a cache line which contains data that differsfrom data stored in corresponding addresses within the associatedmemory. The write-back cache memory further includes cache controllogic, which, upon replacement of a particular cache line within thewrite-back cache memory, writes only identified byte sets to theassociated memory, such that memory accesses and bus utilization areminimized.

A cache is a small amount of expensive high-speed memory, which iscommonly utilized within a data processing system to improve the accesstime to data stored within an associated memory, thereby decreasingprocessor latency. A cache typically comprises a number of cache lines,which each include several bytes of data. Data stored within memory ismapped into a cache utilizing an index portion of the memory addressesassociated with the data, such that multiple memory addresses having thesame index portion map to the same cache line. Cached data associatedwith a particular memory address is distinguished from data associatedwith other addresses having the same index portion by an address tag,typically the high order address bits, which is stored in associationwith the cached data. In order to minimize the conflict between dataassociated with addresses having identical index portions, many cachesprovide multiple ways or storage locations for each cache line.

When data requested by the processor does not reside within the cache, acache miss occurs and the requested data is fetched from memory. Inorder to accommodate the requested data within the cache, the dataresident within a way of the cache line to which the requested data mapsoften must be replaced or “cast-out.” If the cache has multiple ways,the replaced cache location is typically selected utilizing analgorithm, such as a least recently used (LRU) algorithm, in order toavoid casting-out data that has a high probability of being requested bythe processor. A cache location can be similarly replaced or“pushed-out” if a snoop of the cache location reveals that the datacontained within the cache location is inconsistent with more recentdata stored within the corresponding memory address.

Coherency between cached data and data stored in memory is enforced by acache coherency protocol, typically implemented by the processor or acache controller. If a data access is designated as a write-through, anyupdate to the cached data is automatically written to memory, thusenforcing coherency between the cache and the memory upon the completionof the data access. Write-back caches, on the other hand, enforce datacoherency only when a copyback operation is performed in response to acache line replacement or during periods of low bus activity. Becausewrite-back caches entail lower bus utilization, write-back caches aregenerally preferable to write-through caches from a performancestandpoint if the software and hardware environment permit theconcomitant looser coherency.

Cache coherency and replacement operations are typically performed on aline-by-line basis. Accordingly, each way of each cache line within aconventional write-back cache has an associated bit that indicateswhether any of the data bytes contained within the way have beenmodified since the data bytes were written into the cache. When a waythat contains modified data is replaced, a copyback operation is invokedthat writes each byte of the replaced way to the corresponding memoryaddress. Because the length of a cache line is typically several timesthe bandwidth of the bus to which the cache is coupled, such copybackoperations usually require several multi-cycle bus transactions or“beats” to complete.

Although a write-back cache provides enhanced performance compared withcaches implementing a write-though architecture, a conventionalwrite-back cache unnecessarily consumes bus bandwidth when fewer thanall of the data bytes within a replaced way are modified since theunmodified data bytes are written to memory needlessly. The write-backof unmodified data bytes not only consumes bus bandwidth and thereforedecreases overall system performance, but also, as is of particularimportance in battery-powered (e.g., portable) computing environments,dissipates power in enabling the cache and driving the bus.Consequently, it is apparent that a write-back cache is needed thateliminates write-backs of unmodified data to memory.

FIG. 3 depicts a pictorial representation of a data processing system310, which includes an illustrative write-back cache. As illustrated,data processing system 310 includes processor 312, on-board level one(L1) cache 314, optional level two (L2) cache 316, memory 318, systembus 320, processor bus 322, and memory controller 324.

Processor 312 executes software instructions, which are stored in memory318 or are received by processor 312 from another device coupled tosystem bus 320. In order to avoid the latency incurred by repeatedaccesses to memory 318, instructions and data retrieved from memory 318are stored within L1 cache 314 or L2 cache 316 (if present) due to theprobability that the instructions and data will be requested again.Processor 312 preferably comprises one of the PowerPC® line ofmicroprocessors available from IBM Microelectronics of Essex JunctionVt., which operate in accordance with reduced instruction set computing(RISC) techniques; however, those skilled in the art will recognize thatprocessor 312 could also be implemented utilizing an 80×86, PENTIUM (atrademark of Intel Corporation), or other suitable processor.

L1 cache 314 comprises a small (e.g., 216 Kbyte) high-speed memory,which permits the registers and execution units within processor 312rapid access to data and instructions recently retrieved from memory 318via high-speed processor bus 322 and system bus 320. As described above,L1 cache 314 is preferably configured as a write-back cache in order tomaximize the performance of data processing system 310 by reducing thebandwidth of system bus 320 utilized to write back data to memory 318.However, in one embodiment of L1 cache 314, accesses to data containedwithin L1 cache 314 can be configured by software as eitherwrite-through or write-back on a per cache line basis. Althoughillustrated as a unified cache, that is, a cache that stores both dataand instructions, those skilled in the art will appreciate that L1 cache314 can alternatively be implemented as two distinct data andinstruction caches.

As indicated by dashed line illustration, processor 312 can be coupledto an optional L2 cache 316. Like L1 cache 314, L2 cache 316 comprises ahigh-speed memory that contains a subset of the data and instructionsstored within memory 318. In order to maximize data access efficiency,L2 cache 316 is preferably larger in size than L1 cache 314 and is alsoconfigured as a write-back cache. Although illustrated as coupled toprocessor 312 via a dedicated bus 326, those skilled in the art willappreciate that L2 cache 316 can alternatively be implemented on-boardprocessor 312, coupled to processor bus 322 in an in-line or look-asideconfiguration, or coupled to system bus 320.

In the depicted illustrative embodiment, memory 318 comprises a randomaccess memory (RAM) having an associated memory controller 324. Memorycontroller 324 generates read enable and write enable signals tofacilitate storage and retrieval of data and includes addresstranslation facilities that map logical addresses utilized by processor312 into physical addresses within memory 318. As will be appreciated bythose skilled in the art, memory 318 can comprise a number of individualvolatile memory modules which store data and segments of operatingsystem and application software while power is supplied to dataprocessing system 310. Those skilled the art will further appreciatethat in addition to memory 318, numerous types of devices can be coupledto system bus 320 for interaction with processor 312, L1 cache 314, L2cache 316, and memory 318; however, devices not necessary for anunderstanding of the illustrative embodiment described herein have beenomitted for the sake of simplicity.

Referring now to FIG. 4, there is illustrated a pictorial representationof a write-back cache in accordance with the illustrative embodiment ofa data processing system depicted within FIG. 3. Although the write-backcache illustrated within FIG. 4 is identified as L1 cache 314, it willbe understood that the pictorial representation of a write-back cachedepicted within FIG. 4 is equally applicable to L2 cache 316. In thedepicted illustrative embodiment, L1 cache 314 is a two-way setassociative cache comprising a number of cache lines 430, which eachinclude four bus packets P0-P3 in each of two ways. Each bus packetP0-P3 comprises one or more bytes of data and preferably has a packetsize equal to the width of processor bus 322 and system bus 320. Thus,for example, if processor bus 322 and system bus 320 are 64-bit busses,each of bus packets P0-P3 preferably includes 8 bytes of data.

As with conventional caches, data is mapped into a particular cache line430 of L1 cache 314 by an index portion of the memory address whichstores the data. When stored within L1 cache 314, data associated with aparticular memory address is distinguished from data associated withother addresses having the same index portion by an address tag 432,which preferably comprises the high-order bits of the physical addresswithin memory 318 at which the data is stored.

L1 cache 314 further includes coherency protocol bits 434, which in thedepicted embodiment implement the MEI (Modified, Exclusive, Invalid)cache coherency protocol. Those skilled in the art will appreciate thatother cache coherency protocols, for example, the MESI (Modified,Exclusive, Shared, Invalid) protocol, could alternatively be implementedwithin L1 cache 314. Coherency protocol bits 434 comprise one exclusivebit (E) 437, one invalid bit (I) 436, and four modified bits 438(labeled M0-M3) associated with each way of each cache line 430. Whenset, the exclusive bit 437 associated with a particular way of a cacheline 430 indicates that the data block stored within that way iscontained within L1 cache 314 only (not L2 cache 316) and is consistentwith memory 318. The invalid bit 436 associated with a particular way ofa cache line 430 is set to indicate that the data associated with thecorresponding address tag 432 is not resident within L1 cache 314. Forexample, invalid bit 436 is set when a snoop hit occurs during acacheable read or write access to the same location within memory 318 bya second bus master within data processing system 310. Each of modifiedbits (M0-M3) 438 is associated with a particular one of bus packetsP0-P3 within the corresponding cache line way. Modified bits M0-M3 areset when the corresponding bus packet P0-P3 is modified with respect tomemory 318. Thus, setting one of modified bits M0-M3 indicates that datawithin the corresponding bus packet is valid only within L1 cache 314and must eventually be written back to memory 318 to maintain coherency.

Finally, L1 cache 314 includes cache control logic 440. In addition toimplementing a cache coherency protocol by setting and clearingcoherency protocol bits 434, cache control logic 440 generates addresstags from logical addresses and selects cache lines for replacementaccording to an LRU algorithm.

With reference now to FIG. 5, there is illustrated a flowchart of amethod which can be utilized to maintain cache coherency within dataprocessing system 310 of FIG. 3. As illustrated, the process begins atblock 550 when a cache access request is received from processor 312 byL1 cache 314. The process proceeds from block 550 to block 552, whichdepicts cache control logic 440 generating an address tag, that is, thehigh order bits of the physical address of the operand data, based uponthe logical (effective) address of the operand data. In addition, cachecontrol logic 440 maps the cache access request to a specified cacheline 430 utilizing the index portion of the logical address.

Next, the process proceeds from block 552 to block 554, whichillustrates a determination of whether or not the cache access requestis a read request or a write request. In response to a determinationthat the cache access request is a read request, the process proceedsfrom block 554 to block 556.

Block 556 depicts a determination of whether the read request results ina hit or miss. The determination illustrated at block 556 is made bycomparing the address tag generated at block 552 with the address tag432 associated with each way of the specified cache line 430. If thegenerated address tag matches one of the address tags 432 associatedwith a way of the specified cache line 430, a cache hit occurs and theprocess proceeds to block 557, which illustrates L1 cache 314 returningthe requested data to processor 312. Thereafter, the process terminatesat block 570. However, if the read request misses L1 cache 314, theprocess passes to blocks 554-568, which as described below, depict thereplacement of one of the ways of the specified cache line 430 to whichthe memory address of the requested data maps.

Returning to block 554, if a determination is made that the cache accessrequest is a write to the specified cache line 430, the process proceedsfrom block 554 to block 558, which illustrates a determination ofwhether the write request results in a hit or a miss. The determinationillustrated at block 558 is made by comparing the address tag generatedat block 552 with the address tag 432 associated with each way of thespecified cache line 430. If the generated address tag matches one ofaddress tags 432, a hit occurs and the process passes to blocks 560 and562. Blocks 560 and 562 depict updating the appropriate bytes within thespecified cache line 430 and setting the modified bits 438 associatedwith the bus packets containing the updated bytes. Thus, in order toreduce the bus utilization required for write-backs, L1 cache 314indicates the modification of cached data utilizing a smallergranularity than conventional write-back caches. The process thenproceeds from block 562 to block 570, where the process terminates.

Referring again to block 558, if a determination is made that the cacheaccess request results in a miss, that is, that the generated addresstag does not match the address tag 432 associated with either way of thespecified cache line 430, the process passes to blocks 564-568. As notedabove, blocks 564-568 depict the write-back of a selected way of thespecified cache line 430. In the illustrated embodiment, the replacedways are selected according to an LRU algorithm that can be implementedby associating a single LRU bit with each of cache lines 430; however,those skilled in the art will appreciate that other replacement schemescan also be employed.

Still referring to FIG. 5, block 564 illustrates cache control logic 440examining the modified bits 438 associated with the way selected forreplacement within the specified cache line 430 in order to identifywhich of bus packets P0-P3 have been modified. Next, the processproceeds to block 566, which depicts writing only the bus packets markedas modified to memory 318. In contrast to conventional write-backcaches, bus packets which are not marked as modified are simply cast outand are not written back to memory 318, thereby reducing the busutilization required for a write-back. Next, the process proceeds toblock 568, which illustrates fetching a data block containing therequested data from L2 cache 316 or memory 318 and writing the datablock into the selected way of the specified cache line 430. Inaddition, the modified bits 438 associated with the selected way are setor cleared to indicate which bus packets P0-P3 contain modified data.Thus, if the replacement of the selected way was performed in responseto a read miss, all of the modified bits 438 associated with theselected way are cleared; however, if the way was replaced due to awrite miss, one or more modified bits 438 are set to indicate which ofbus packets P0-P3 contain modified data. Thereafter, the process passesto block 570 and terminates.

A paper titled “Dynamically Variable Line-Size Cache Architecture forMerged DRAM/Logic LSIs” by Koji Inoue, Koji Kai, and Kazuaki Murakami,published in IEICE Transactions on Information and Systems, Vol. E83-D,No. 5, pp. 1048-1057, May 2000, incorporated herein by reference in itsentirety, proposes a novel cache architecture suitable for mergedDRAM/logic LSIs, which is called “dynamically variable line-size cache”(D-VLS cache). The D-VLS cache can optimize its line-size according tothe characteristic of programs, and attempts to improve the performanceby exploiting the high on-chip memory bandwidth on merged DRAM/logicLSIs appropriately. An average memory-access time improvement achievedby a direct-mapped D-VLS cache may be about 20% compared to aconventional direct-mapped cache with fixed 32-byte lines. Thisperformance improvement may be better than that of a doubled-sizeconventional direct-mapped cache.

Integrating processors and main memory (DRAM) on the same chip, ormerged DRAM/logic LSI, can offer a number of advantages for breakingtechnological limitations of conventional system design. Especially, thehigh on-chip memory bandwidth, which may be one of the advantages of themerged DRAM/logic LSIs, may produce significant performance advantages,because it can improve data-transferability between the processors andthe main memory dramatically.

For merged DRAM/logic LSIs with a memory hierarchy including cachememory, high on-chip memory bandwidth can be exploited by means ofreplacing a whole cache line at a time on cache misses. This approachtends to increase the cache line size when attempting to improve theattainable memory bandwidth. In general, large cache lines can benefitsome application as the effect of prefetching. Larger cache lines,however, might worsen the system performance if programs do not haveenough spatial locality and cache misses frequently take place. Thesekinds of cache misses (i.e., conflict misses) could be reduced byincreasing the cache associativity. But this approach may make the cacheaccess time longer.

To resolve the above-mentioned dilemma, a concept of “variable line-sizecache (VLS cache)” is proposed. The VLS cache can alleviate the negativeeffects of larger cache line size by partitioning the large cache lineinto multiple small cache lines. The performance of the VLS cache maydepend largely on whether or not cache replacements can be performedwith adequate line-sizes. There may be at least two approaches tooptimizing the cache line sizes: one is a static determination based oncompiler analysis; the other is a dynamic determination using somerun-time hardware support. It may be possible to adopt the formerapproach when target programs have regular access patterns withinwell-structured loops. However, a number of programs have non-regularaccess patterns. In addition, when a lot of programs run concurrently,the amount of spatial locality will vary both within and among programs.

One of the latter approaches is proposed, which is referred to as“dynamically variable line-size cache (D-VLS cache)” architecture, andevaluates the cost/performance improvements attainable by the D-VLScache. The D-VLS cache may change its cache line size at run timeaccording to the characteristics of application programs to execute.Line-size determinator selects adequate line-sizes based on recentlyobserved data reference behavior. Since this scheme may not require anymodification of instruction set architectures, the full compatibility ofexisting object codes can be kept. A goal of D-VLS cache is to improvethe system performance of merged DRAM/logic LSIs such as PPRAM (ParallelProcessing RAM) or IRAM (Intelligent RAM) by making good use of the highon-chip memory bandwidth.

Several studies have proposed coherent caches in order to produce theperformance improvement of shared memory multiprocessor systems. In oneproposal, the cache can adjust the amount of data stored in a cacheline, and aims to produce fewer invalidations of shared data and reducebus or network transactions. On the other hand, the VLS cache aims atimproving the system performance of merged DRAM/logic LSIs bypartitioning a large cache line into multiple independently small cachesublines, and adjusting the number of sublines to be enrolled on cachereplacements. A fixed and adaptive sequential prefetching proposalallows us to fetch more than one consecutive cache line. This approachmay need a counter for indicating the number of lines to be fetched.Regardless of the values of memory reference addresses, the counter maybe used for fetching cache lines on read misses. On the other hand, theD-VLS cache may have several flags indicating the cache line size. Whichflag should be used depends on memory reference addresses. In otherwords, the D-VLS cache can change the cache line size not only along theadvance of program execution but also across data located in differentmemory addresses.

Excellent cache architectures exploiting spatial locality have beenproposed. Some proposed caches need tables for recording the memoryaccess history of not only cached data but also evicted data from thecache. Similarly, some proposed caches use a table for storing thesituations of past load/store operations. In addition, the detection ofspatial locality may rely on the memory access behavior derived fromconstant-stride vector accesses. On the other hand, the D-VLS cache maydetermine a suitable cache line size based on only the state of thecache line which is currently being accessed by the processor.Consequently, the D-VLS cache may have no large tables for storing thememory access history. Just a single bit may be added to each cache-tagfor storing the memory access history.

Furthermore, the D-VLS cache attempts to make good use of the highon-chip memory bandwidth available on merged DRAM/logic LSIs. Since thehigh on-chip memory bandwidth allows for the transfer of any number ofdata (up to the width of on-chip memory bus) at a time, the D-VLS cachecan utilize very large cache lines, for example 128-byte cache lines,without increasing miss penalty. The cache replacement may alwayscomplete in a constant time regardless of the cache line sizes selected.

Variable Line-Size (VLS) Cache

Terminology

In the VLS cache, an SRAM (cache) cell array and a DRAM (main memory)cell array may be divided into several subarrays. Data transfer forcache replacements may be performed between corresponding SRAM and DRAMsubarrays. FIG. 6 is a block diagram of an example VLS cache 605 andsummarizes the definition of terms.

Address-block 610, or subline, is a block of data associated with asingle tag in the cache. Transfer-block 615, or line, is a block of datatransferred at once between the cache 605 and main memory 620. Theaddress-blocks from every SRAM subarray, which have the samecache-index, form a cache-sector 625. A cache-sector and anaddress-block which are being accessed during a cache lookup are calleda reference-sector 630 and a reference-subline 635, respectively. When amemory reference from the processor has found a cache hit, referenceddata resides in the reference-subline. Otherwise, referenced data is notin the reference-subline but only in the main memory 620. Amemory-sector 640 is a block of data in the main-memory, and correspondsto the cache-sector. Adjacent-subline 645 is defined as follows.

-   -   It resides in the reference-sector, but is not the        reference-subline.    -   Its home location in the main-memory is in the same        memory-sector as that of the data which is currently being        referenced by the processor.    -   It has been referenced at least once since it was fetched into        the cache.        Concept and Principle of Operations

To make good use of the high on-chip memory bandwidth, the VLS cacheadjusts its transfer-block size according to the characteristics ofprograms. When programs have rich spatial locality, the VLS cache woulddetermine to use larger transfer-blocks, each of which consists of lotsof address-blocks. Conversely, the VLS cache would determine to usesmaller transfer blocks, each of which consists of a single or a fewaddress-blocks, and could try to avoid cache conflicts.

The construction of the example direct-mapped VLS cache 605 illustratedin FIG. 6 is similar to that of a conventional 4-way set-associativecache. However, the conventional 4-way set-associative cache has fourlocations where a sub-line can be placed, while the direct-mapped VLScache has only one location for a sub-line, just like a conventionaldirect-mapped cache. Since the VLS cache can avoid cache conflictswithout increasing the cache associativity, the access time (i.e., hittime) is shorter than that of conventional caches with higherassociativity.

The VLS cache works as follows: (1) When a memory access takes place,the cache tag array is looked up in the same manner as normal caches,except that every SRAM subarray has its own tag memory and the lookup isperformed on every tag memory. (2) On cache hit, the hit address-blockhas the required data, and the memory access performs on thisaddress-block in the same manner as normal caches. (3) On cache miss, acache refill takes place as follows: (a) according to the designatedtransfer-block size, one or more address-blocks are written back fromthe indexed cache-sector to their home locations in the DRAM mainmemory; and (b) according to the designated transfer-block size, one ormore address-blocks (one of which contains the required data) arefetched from the memory-sector to the cache-sector.

For the example VLS cache shown in FIG. 7, there are three possibletransfer-block sizes as follows:

-   -   Minimum transfer-block size 710, where only the designated        address-block is involved in cache replacements.    -   Medium transfer-block size 720, where the designated        address-block and one of its neighbors in the corresponding        cache-sector are involved.    -   Maximum transfer-block size 730, where the designated        address-block and all of its neighbors in the corresponding        cache-sector are involved.        Dynamically VLS (D-VLS) Cache        Architecture

The performance of the VLS cache depends heavily on how well the cachereplacement is performed with optimal transfer-block size. However, theamount of spatial locality may vary both within and among programexecutions. The line-size determinator for the D-VLS cache selectsadequate line-sizes based on recently observed data reference behavior.

FIG. 8 illustrates a block diagram of an example direct-mapped D-VLScache 805 with four subarrays 840. The address-block size is 32 bytes,with the following three transfer-block sizes:

-   -   Minimum transfer-block size (=32 bytes) involving just one (=2⁰)        address-block,    -   Medium transfer-block size (=64 bytes) involving two (=2¹)        address-blocks, and    -   Maximum transfer-block size (=128 bytes) involving four (=2²)        address-blocks.

Since it is not allowed that the medium transfer-block misaligns withthe 64-byte boundary in the 128-byte cache-sector, the number ofpossible combinations of address-blocks involved in cache replacementsis just seven (four for minimum, two for medium, and one for maximumtransfer-block size, respectively) rather than fifteen (=2⁴−1).

The D-VLS cache provides the following for optimizing the transfer-blocksizes at run time:

A reference-flag bit 810 per address-block: This flag bit is reset to 0when the corresponding address block is fetched into the cache, and isset to 1 when the address-block is accessed by the processor 815. It isused for determining whether the corresponding address block is anadjacent-subline. On cache lookup, if the tag of an address-block whichis not the reference-subline matches the tag field of the address and ifthe reference flag bit is 1, then the address-block is an adjacentsubline.

A line-size specifier (LSS) 820 per cache-sector: this specifies thetransfer-block size of the corresponding cache-sector. Preferably, eachcache-sector is in one of three states: minimum, medium, or maximumtransfer-block-size states. To identify these states, every LSS providesa 2-bit state information. This means that the cache replacement isperformed according to the transfer-block size which is specified by theLSS corresponding to the reference sector. The LSS is maintained in theLSS-table 825, as shown in FIG. 8.

Line-size determinator (LSD) 830: On every cache lookup, the LSDdetermines the state of the line-size specifier of the reference-sector.The D-VLS cache works as follows: (1) The address generated by theprocessor is divided into the byte offset within an address-block,subarray field designating the subarray, index field used for indexingthe tag memory, and tag field. (2) Each cache subarray has its own tagmemory and comparator, and it can perform the tag-memory lookup usingthe index and tag fields independently with each other. At the sametime, the LSS corresponding to the reference-sector is read using theindex field from the LSS-table. (3) One of the tag-comparison results isselected by the subarray field of the address, and then the cache hit ormiss is determined. (4) On cache miss, a cache replacement is performedaccording to the state of the LSS. (5) Regardless of hits or misses, theLSD determines the state of the LSS. After that, the LSD writes back themodified LSS to the LSS-table.

Line-Size Determinator Algorithm

The algorithm for determining adequate transfer-block sizes is verysimple. This algorithm is based not on memory-access history but on thecurrent state of the reference-sector. This means that no information ofevicted data from the cache needs to be maintained. On every cachelookup, the LSD determines the state of the LSS of the reference-sector,as follows: (1) The LSD investigates how many adjacent-sublines exist inthe reference-sector using all the reference flag bits and thetag-comparison results. (2) Based on the above-mentioned investigationresult and the current state of the LSS of the reference sector, the LSDdetermines the next state of the LSS.

If there are many neighboring adjacent-sublines, the reference-sectorhas good spatial locality. This is because the data currently beingaccessed by the processor and the adjacent-sublines are fetched from thesame memory-sector, and these sublines have been accessed by theprocessor 815 recently. In this case, the transfer-block size shouldbecome larger. Thus the state may transit from the minimum state(32-byte line) to the medium state (64-byte line) or from the medium(64-byte line) state to the maximum state (128-byte line) when thereference-subline and adjacent-sublines construct a larger line-sizethan the current line-size.

In contrast, if the reference-sector has been accessed sparsely beforethe current access, there should be few adjacent-sublines in thereference-sector. This means that the reference-sector has poor spatiallocality at that time. In this case, the transfer-block size shouldbecome smaller. So the state transits from the maximum state (128-byteline) to the medium state (64-byte line) when the reference subline andadjacent-sublines construct equal or smaller line-size than the mediumline-size (64-byte or 32-byte line). Similarly, the state transits fromthe medium state (64-byte line) to the minimum state (32-byte line) whenthe reference-subline and adjacent-sublines construct minimum line-size(32-byte line).

As previously described, transactional semantics in transactional memorysystems may be enforced by tracking the memory locations read andwritten by each transaction. If multiple transactionally executinglogical processors or processor threads access the same memory in aconflicting way, one or more of the competing transactions may beaborted. For example, two accesses from two different transactions ofthe same memory location may be conflicting if at least one of theaccesses is a write.

Transactional memory systems may leverage a cache coherence protocol toenforce transactional semantics, using cache lines as the granularity ofmemory accesses to detect transaction conflicts. For example, each cacheline may be associated with transactional access bits in addition to thevalid bit, coherence state bits, and other descriptive bits that may beassociated with the cache line for maintaining cache coherence and forother various uses. A transactional read bit (R) may be added toindicate whether any part of a cache line has been read during executionof a transaction. A transactional write bit (W) may be added to indicatewhether any part of a cache line has been written during execution of atransaction. If a processor is multithreading capable, all or some ofsaid bits might be kept per thread activities.

When transactional accesses are monitored using cache lines, transactionconflicts may result when multiple transactionally executing processorsin the computing environment access any part of the same cache line in aconflicting manner. A false conflict may occur when a first transactionaccesses memory address A, a second transaction concurrently accessesmemory address B, and addresses A and B reside in the same cache line.Although the transactions are accessing different memory locations, thelocations A and B are in close enough proximity to be included in asingle cache line. Such false conflicts can lead to performancedegradation. Smaller cache line sizes can minimize the occurrence offalse conflicts; however, smaller cache line sizes can also adverselyaffect system performance in other ways.

The frequency of false transaction conflicts may be reduced whileretaining the benefits of larger cache line sizes by using aconfigurable cache line size. With a configurable cache line size, cachelines that are involved in a high number of transaction conflicts may beidentified and managed with a finer sub-cache line granularity. Theremaining cache lines may continue to be managed with the full cacheline granularity and therefore continue to provide the benefits of thelarger cache line size. The number of cache lines designated ashigh-conflict cache lines may be kept below a certain number or below acertain percentage of cache lines in the environment to avoid adverselyimpacting performance.

Cache control logic enforcing a coherence protocol with a configurablecache line size may manage the data in the caches at the granularity ofa full cache line by default. Each cache line in full-line coherencymode is managed as a full cache line, while each cache line in sub-linecoherency mode is managed as a plurality of sub-cache line portions of afull cache line. For example, if the normal (default) cache line size is256 bytes, full cache lines of 256 bytes are accessed, owned, shared,cast-out, invalidated, and otherwise operated and/or managed for cachelines in full-line coherency mode, while sub-cache line portions of lessthan 256 bytes are accessed, owned, shared, cast-out, invalidated, andotherwise operated and/or managed for cache lines in sub-line coherencymode. A normal, full cache line of 256 bytes may be managed as twosub-lines of 128 bytes each, as four sub-lines of 64 bytes each, or insome other manner when in sub-line coherency mode. A full cache line of1024 bytes may be managed as two sub-lines of 512 bytes each, as eightsub-lines of 128 bytes each, or in some other manner when in sub-linecoherency mode. The number and size of the sub-cache line portions maybe fixed or programmable.

FIG. 9 illustrates an example method 900 for detecting and reducingtransaction conflicts that may reduce the number of false conflicts. Atstart 910, if a logical processor in the computing environment isexecuting a transaction at 915, and if that transaction will beaccessing a cache line at 920, then the method determines whether thecache line that will be accessed by the transaction is already insub-line coherency mode at 925. A cache line may be in sub-linecoherency mode for any number of reasons. For example, a cache line maybe in sub-line coherency mode because it has been previously determinedto be a high-conflict cache line. Determining whether a cache line is insub-line coherency mode may be accomplished by checking a flag bit forthe cache line in a cache, by checking for representation of the cacheline in a list or table maintained for a processor or group ofprocessors, or may be accomplished in some other way. In someembodiments, determining whether a cache line is in sub-line coherencymode may be accomplished indirectly, for example by determining that thecache line is a high-conflict cache line.

If the cache line is in sub-line coherency mode at 925, then only therelevant sub-cache line portion of the cache line is accessed and markedas transactionally accessed at 930. The relevant sub-cache line portionis the sub-cache line that includes a copy of the memory addresstargeted in an operation by the transaction. The remaining non-relevantsub-cache line portions of the cache line are not accessed. As anexample, for a cache line in sub-line coherency mode managed as foursub-cache lines, if the transaction writes memory address A, and ifmemory address A is associated with the third sub-cache line portion ofthe cache line, then a transactional W bit associated with the thirdsub-cache line may be set, while the W bits associated with the first,second, and fourth sub-cache lines may remain clear. A concurrent accessby another transaction of the third sub-cache line may still result in aconflict, but a concurrent access by another transaction of the first,second, or fourth sub-cache line will not result in a conflict.

If the cache line is not in sub-line coherency mode at 925, even whenthe cache line is not necessarily accessed in full, the full cache lineis marked as transactionally accessed at 940. A transactional R bit, Wbit, or other bit associated with the full cache line may be set,depending on the type of access.

Alternatively at start 910, if a transaction conflict is detected for atransactionally accessed cache line at 935, then one or more of theconflicting transactions is aborted at 945. A contention managementpolicy, examples of which are described above, may govern which of theconflicting transactions is aborted. The method then determines whetherthis cache line is a high-conflict cache line at 950. Methods fordetermining whether a cache line is a high-conflict cache line arediscussed below, and may include, for example, examining a flag or otherindicator associated with the cache line, or by examining a counterassociated with the cache line in a conflict address detection table.

If the cache line is determined to be a high-conflict cache line at 950,then the cache line is placed in sub-line coherency mode at 955, andsubsequently, new transactions will access the cache line at a sub-cacheline granularity. Placing the cache line in sub-line coherency mode mayor may not include, for example, setting a flag or other externalindicator associated with the cache line, or placing an entryrepresenting the cache line in a table or list. The high-conflict cacheline may remain in full-line coherency mode in other caches that are notaware of the cache line's high-conflict status.

Placing a high-conflict cache line in sub-line coherency mode at 955 mayreduce the occurrence of false conflicts since a smaller range of memoryaddresses are marked during transactional accesses at 930. However,access patterns for cache lines may change over time, and a cache linethat once was a high-conflict cache line may no longer be associatedwith a high number of conflicts. A similar method used to determine whena cache line qualifies as a high-conflict line may also be used todetermine if a high-conflict cache line transitions to a typical,acceptable, or normal number of transactional conflicts. Such a formerhigh-conflict cache line may then be returned to full-line coherencymode. Alternatively, a high-conflict cache line may be reset to normal,full-line coherency mode periodically, for example after a thresholdamount of time or a threshold number of processor cycles has elapsed, orafter a threshold number of instructions or transactions has completed.A former high-conflict cache line that again meets the high-conflictrequirements may be returned to sub-line coherency mode. Accordingly, acache line may periodically transition between high-conflict and normalstatus.

A configurable cache line size may also be effective in reducing theamount of false sharing of cache lines in a multi-processor computingenvironment, with or without transactional memory. False sharing occurswhen multiple processors access the same cache line in a conflictingmanner, but each processor is targeting a distinct, non-overlappingportion of the cache line. For example, when a first processor writes toa memory location in a copy of a cache line residing in a first cache,cache control logic following a cache coherence protocol may invalidateall other copies of that cache line residing in other caches. Asubsequent read of an invalidated copy of the shared cache line from asecond cache is termed a coherence miss, and a coherence request must beissued to update the second cache with the most recent version of thecache line. The most recent version may be obtained directly from thefirst cache, may be obtained from a higher level cache, or may beobtained from main memory depending on the coherence protocol and otherfactors in the computing environment.

False sharing may occur when a first processor writes to a cache line ina first cache targeting memory address A, invalidating all other cachecopies of the cache line and causing a subsequent coherence miss duringan access of memory address B in a second cache by a second processor.Although the processors are accessing different memory locations, thelocations A and B are in close enough proximity to be included in asingle cache line. Such false sharing can lead to performancedegradation. Smaller cache line sizes can minimize false sharing;however, smaller cache line sizes can also adversely affect systemperformance in other ways.

The amount of false sharing may be reduced while retaining the benefitsof larger cache line sizes by using a configurable cache line size. Witha configurable cache line size, cache lines that are involved in a highnumber of coherence misses may be identified and managed with a finersub-cache line granularity. The remaining cache lines may continue to bemanaged with the full cache line granularity and therefore continue toprovide the benefits of the larger cache line size. The number of cachelines designated as high-coherence-miss cache lines may be kept below acertain number or below a certain percentage of cache lines in theenvironment to avoid adversely impacting performance.

FIG. 10 illustrates an example method 1000 for cache management that mayreduce the incidence of false sharing. At start 1010, if a logicalprocessor in the computing environment will be accessing a cache line at1020, and if the logical processor has a valid copy of the cache line inits local cache at 1025, then the method determines whether the cacheline that will be accessed is already in sub-line coherency mode at1035. A cache line may be in sub-line coherency mode for any number ofreasons. For example, a cache line may be in sub-line coherency modebecause it has been previously determined to be a high-conflict cacheline or a high-coherence-miss cache line. Determining whether a cacheline is in sub-line coherency mode may be accomplished by checking aflag bit for the cache line in a cache, by checking for representationof the cache line in a list or table maintained for a processor or groupof processors, or may be accomplished in some other way. In someembodiments, determining whether a cache line is in sub-line coherencymode may be accomplished indirectly, for example by determining that thecache line is a high-coherence-miss cache line.

If the cache line is in sub-line coherency mode at 1035, then only therelevant sub-cache line portion of the cache line is accessed at 1030.The relevant sub-cache line portion is the sub-cache line that includesa copy of the memory address targeted in an operation by the processor.The remaining non-relevant sub-cache line portions of the cache line arenot accessed. As an example, for a cache line in sub-line coherency modemanaged as four sub-cache lines, if the processor accesses memoryaddress A, and if memory address A is associated with the secondsub-cache line portion of the cache line, then only the coherence stateof the second sub-cache line is relevant. If the second sub-cache linehas been invalidated and the access requires a clean copy, then acoherence miss will result. Whether the first, third, and fourthsub-cache lines are invalidated is irrelevant. If the cache line is notin sub-line coherency mode at 1035, then the full cache line isconsidered to be accessed at 1040. If the processor is performing awrite operation, then all copies of the cache line in other caches maybe invalidated.

If the logical processor does not have a valid copy of the cache line inits local cache at 1025, then a request is issued for the cache line at1045. In some cases, the cache line was previously invalidated from thelocal cache due to a coherence event; such a cache miss may be called acoherency miss. The method then determines whether this cache line is ahigh-coherence-miss cache line at 1050. Methods for determining whethera cache line is a high-coherence-miss cache line are discussed below,and may include, for example, examining a flag or other indicatorassociated with the cache line, or by examining a counter associatedwith the cache line in a coherence miss detection table.

If the cache line is not a high-coherence-miss cache line at 1050, thenthe cache line remains in full-line coherency mode, the full cache lineis accessed at 1060. But if the cache line is determined to be ahigh-coherence-miss cache line at 1050, then the cache line is placed insub-line coherency mode at 1055, and a relevant sub-cache line portionof the cache line is accessed at 1065. Placing the cache line insub-line coherency mode may or may not include, for example, setting aflag or other external indicator associated with the cache line, orplacing an entry representing the cache line in a table or list. Thehigh-coherence-miss cache line may remain in full-line coherency mode inother caches that are not aware of the cache line's high-coherence-missstatus.

Placing a high-coherence-miss cache line in sub-line coherency mode at1055 may reduce the occurrence of false sharing since a smaller range ofmemory addresses are invalidated in conjunction with a write operation.However, access patterns for cache lines may change over time, and acache line that once was a high-coherence-miss cache line may no longerbe associated with a high number of coherence misses. A similar methodused to determine when a cache line qualifies as a high-coherence-missline may also be used to determine if a high-coherence-miss cache linetransitions to a typical, acceptable, or normal number of coherencemisses. Such a former high-coherence-miss cache line may then bereturned to full-line coherency mode. Alternatively, ahigh-coherence-miss cache line may be reset to normal, full-linecoherency mode periodically, for example after a threshold amount oftime or a threshold number of processor cycles has elapsed, or after athreshold number of instructions or cache misses has completed. A formerhigh-coherence-miss cache line that again meets the high-coherence-missrequirements may be returned to sub-line coherency mode. Accordingly, acache line may periodically transition between high-coherence-miss andnormal status.

FIG. 11 is a block diagram representing an example system 1100 foridentifying high-contention cache lines such as high-conflict cachelines and high-coherence-miss cache lines, and other problematic cachelines. Processor 1110 contains cache control logic 1112 and isassociated with a cache 1115 holding a number of cache lines 1120. Thecache 1115 may include a cache directory 1130 with an entry for eachcache line 1120. For each cache line, the directory may include a tagthat identifies the locations in main memory represented in the cacheline. Although system 1100 shows a simplified cache structure with asimple identifying tag associated with a single line of contiguousmemory, any cache configuration that associates an identifier with aportion of memory is contemplated. Cache directory 1130 may also includea set of descriptive bits that provides information about the cacheline. The set of descriptive bits may include a valid bit, a set ofcoherence state bits (for example, MESI bits), transactional accessbits, and other bits describing attributes of the cache line.

Detection table 1140 is a table of counters that may be used to trackthe number of times any particular cache line 1120 is contended in aparticular manner. For example, detection table 1140 may be a conflictaddress detection table for tracking the number of transaction conflictsassociated with a particular cache line, or may be a coherence missdetection table for tracking the number of coherence misses associatedwith a particular cache line. In some embodiments, detection table 1140may be a combination table that can track multiple types of qualifyingcontentions of the cache line. Detection table 1140 may be part of thesame cache structure that includes directory 1130 and cache lines 1120or may be independent of that cache structure.

Each entry in detection table 1140 corresponds to an individual cacheline 1120, and may be identified using the same tag used to identify thecache line in the cache directory. Each entry may include one or morecounters associated with each cache line. A counter may be incremented,for example by detection logic in processor 1110, with each qualifyingcontention of the cache line. The counters may be saturating counters toavoid rolling over to zero if the counters' maximum values are reached.Detection table 1140 may be preconfigured to hold a fixed number ofentries or may be of variable or programmable size. In some embodiments,a hash of the tag used in the directory may be used for identificationin the detection table 1140 to reduce the amount of address bits used.In some embodiments, an entry in the detection table 1140 may representmultiple adjacent cache lines.

Ideally, detection table 1140 may be small compared to the cache sizeand may have fewer entries than the number of cache lines 1120 in thecache 1115; therefore not every cache line in the cache may be trackedin detection table 1140. In example system 1100, the first two cachelines in the cache, identified in cache directory 1130 by TAG 1 and TAG2, have corresponding entries in detection table 1140 and therefore havecounters that are tracking the qualifying contentions of those cachelines. The third cache line, identified in cache directory 1130 by TAG3, does not have an entry in detection table 1140, indicating that thethird cache line has not experienced a qualifying contention since thelast time that detection table 1140 was cleared, or since the last timethat the third cache line's entry was invalidated or removed from thedetection table, for example to make room for a new entry. Qualifyingcontentions may be one or more of transaction conflicts, coherencemisses, or other types of contentions where reducing the cache line sizecan reduce false positives and improve performance. Since replacementsof the cache can be managed differently than replacements in thedetection table, an entry, such as TAG X, in the detection table, maynot exist concurrently in the cache directory 1130. In some embodiments,when a cache line ages out of the cache 1115, any corresponding entriesin detection table 1140 may be invalidated.

Detection table 1140 may track a single type of qualifying contention ormultiple types. For example, detection table 1140 may be a conflictaddress detection table for identifying high-conflict cache lines, ormay be a coherence miss detection table for identifyinghigh-coherence-miss cache lines. In some embodiments, detection table1140 may track more than one type of qualifying contention eitherindividually or combined. For example, detection table 1140 may have asingle entry for a cache line with separate counters for transactionconflicts and coherence misses. Alternatively, detection table 1140 mayhave a single entry for a cache line with a single counter for bothtransaction conflicts and coherence misses.

FIG. 12 illustrates an example method 1200 for identifying problematiccache lines, such as high-conflict cache lines and high-coherence-misscache lines. Method 1200 may be used in conjunction with example system1100 of FIG. 11 or with any other system configured with a detectiontable suitable for tracking cache line contentions. Method 1200 may alsobe used in conjunction with method 900 of FIG. 9 and/or method 1000 ofFIG. 10 to identify problematic cache lines. In some embodiments, cachelines identified as problematic will be placed in sub-line coherencymode.

At start 1210, one or more counters in a detection table are cleared,reset, or otherwise initialized at 1215. The counters may bereinitialized periodically if criteria is met that indicates that it istime to reset the counters at 1220. Although method 1200 describes aspecific action taken at 1220 to determine whether it is time to resetthe counters after detecting and processing performance-reducing events,such as a cache line contention, this function may be a timer or otherseparate process running concurrently with the detection logic. Anysuitable protocol for periodically clearing the counters can beutilized, for example, after every billion processing cycles, or everymillisecond. Associated cache lines in sub-line coherency mode mayrevert to full-line coherency mode when the counters are cleared. Someembodiments may not periodically clear the entire detection table, andmay rely on other mechanisms to ensure that no individual entry remainsin the table past its usefulness. Each counter in the table may beassociated with one or more reset criteria, and the counter may be resetwhen an associated reset criterion is satisfied. Reset criteria mayinclude, for example, a period of time has elapsed, a number ofinstructions have completed, or a cache line associated with the counteris cast out of a cache. Because application behavior changes over time,cache lines that were previously problematic may later benon-problematic, and detection mechanisms preferably are designed toallow formerly problematic cache lines to revert to full-line coherencymode.

If it is not time to reset the counters at 1220, then the methoddetermines at 1225 whether a qualifying performance-reducing event hasoccurred associated with a cache line in full-line coherency mode, suchas detection of a transaction conflict or of a coherence miss. If suchan event has occurred at 1225, the method checks whether the cache linehas an associated entry in the detection table at 1230. If the detectiontable already has an entry for the cache line at 1230, then a counterassociated with that entry is incremented at 1235.

If the incremented counter satisfies a high-contention criterion at1240, such as a high-conflict criterion or a high-coherence-misscriterion, then the cache line is a problematic cache line. Thehigh-contention criterion may be predetermined for the computingenvironment or may be configurable, user-selectable, or dynamicallydetermined at program run-time. In some embodiments, the criterion maybe satisfied when the incremented counter reaches a threshold value. Insome embodiments, the criterion may be satisfied when the incrementedcounter reaches a threshold percentage of the total number of conflicts,coherence misses, or other performance-impacting events in the computingenvironment. For example, a cache line could be problematic if it isresponsible for 1% of all conflicts.

In some embodiments, if the incremented counter satisfies thehigh-contention criterion at 1240, an indicator may be set at 1245 todefine the cache line as a high-contention cache line, and the indicatormay be subsequently passed to other caches according to a cachecoherence protocol. For example, returning briefly to FIG. 11,descriptive bits in directory 1130 may include a high-conflict indicator1160. A cache line determined to be a high-conflict cache line may haveits high-conflict indicator set at 1245, so that logic subsequentlyaccessing the cache line can examine the indicator to determine whetherthe cache line is a high-conflict cache line. In some embodiments, noindicator is set. When no indicator is set, logic subsequently accessingthe cache line may examine the detection table and the countersassociated with the cache line to determine whether the cache line is aproblematic cache line.

If the detection table has no entry for the cache line at 1230, then anew entry for the cache line may be placed in the detection table. Ifthe detection table has unused entries available at 1255, then the newentry may be added to the table at 1265. If the detection table has nounused entries available at 1255, then an existing entry may be replacedat 1260. The counters associated with the new entry may then beinitialized at 1270 to show that a first performance-reducing eventassociated with the cache line has been detected. If the new entry isreplacing an existing entry, any suitable protocol for selecting acandidate entry for replacement may be followed. For example, the leastrecently used or updated entry may be replaced, or the entry with thesmallest counter value may be replaced.

For embodiments that set an indicator at 1245, an example method 1300for cache management that may reduce the incidence of transactionconflicts is illustrated in FIG. 13. Although method 1300 isspecifically for transaction conflicts, a similar method could be usedfor coherence misses and other events that may reduce the incidence offalse sharing and other performance-impacting events. At start 1310, ifa logical processor in the computing environment is executing atransaction at 1315, and if that transaction will be accessing a cacheline at 1320, then the method examines a high-conflict indicatorassociated with the cache line at 1330.

If the high-conflict indicator is set at 1340, then the cache line is insub-line coherency mode and only the relevant sub-cache line portion ofthe cache line is accessed and marked as transactionally accessed at1360. The relevant sub-cache line portion is the sub-cache line thatincludes a copy of the memory address targeted in an operation by thetransaction. The remaining non-relevant sub-cache line portions of thecache line are not accessed. If the high-conflict indicator is not setat 1340, then the cache line is in full-line coherency mode. Even whenthe cache line is not necessarily accessed in full, the entire cacheline is marked as transactionally accessed at 1350 when in full-linecoherency mode.

In some embodiments, the high-conflict indicator is one of thedescriptive bits associated with the cache line; therefore a copy of thehigh-conflict indicator resides in each cache that has a copy of thecache line. Detection logic associated with a first cache may determinethat the cache line is a high-conflict cache line and set thehigh-conflict bit for that line in the first cache. Even if detectionlogic associated with a second cache has not determined that the cacheline is a high-conflict cache line, if that second cache obtains anupdated copy of the cache line, directly or indirectly from first cache,the high-conflict bit may be set.

A high-conflict indicator may be associated with one or more resetcriteria, and the indicator may be reset when an associated resetcriterion is satisfied. Reset criteria may include, for example, aperiod of time has elapsed, a number of instructions have completed, ora cache line associated with the counter is cast out of a cache.

FIG. 14 illustrates a high-level view of an example computingenvironment 1400 for identifying high-conflict cache lines,high-coherence-miss cache lines, and other types of problematic cachelines. Computing environment 1400 includes N processor systems 1410communicating over interconnect 1460. Each processor 1420 is associatedwith a low level local cache 1430 and a detection table 1440, makingeach processor system 1410 analogous to system 1100 from FIG. 11 in someembodiments. The N processors 1420 may also be associated with one ormore high level shared caches 1450 connected in a predeterminedtopology.

Each processor 1420 has detection logic for identifying problematiccache lines in its associated cache 1430. This detection logic may trackconflicts, coherence misses, and/or other performance-reducing events inits associated detection table 1440. For example, Processor 1 managesdetection table D1, whose entries correspond to entries in Cache 1,while Processor 2 manages detection table D2, whose entries correspondto entries in Cache 2.

Any or all caches 1430 may have a copy of a particular cache line at anygiven time. Consequently, multiple detection tables 1440 may be trackingconflicts, coherence misses, and/or other events for the same cacheline. For example, Cache 1 may have a copy of Cache Line A, anddetection table D1 may have an entry showing that Cache Line A is ahigh-conflict cache line. Cache 2 may have a copy of Cache Line A, butdetection table D2 may have no entry showing that Cache Line A is ahigh-conflict cache line. Detection table D2 may have either no entry atall for Cache Line A, or may have an entry with a counter that has notsatisfied the high-conflict criterion. Both Cache N and detection tableDN may have no entry at all for Cache Line A. In this example, onlyProcessor 1 has determined that Cache Line A is a high-conflict cacheline, and therefore only Processor 1 may be realizing increasedperformance by detecting conflicts for Cache Line A with sub-linegranularity rather than with full-line granularity.

Expanding the example to an embodiment including a high-conflict cacheline indicator for each cache line, such as indicator 1160 in FIG. 11,Processor 1 can set this indicator for Cache Line A after determiningthat Cache Line A is a high-conflict cache line. Detection logic inProcessor 1 may subsequently invalidate the entry for Cache Line A indetection table D1 to make room for another entry. The next time CacheLine A is refreshed in Cache 2, the indicator will be copied andProcessor 2 can determine that Cache Line A is a high-conflict cacheline by examining the indicator. In this example, Processor 2 candetermine that Cache Line A is a high-conflict cache line without evertracking Cache Line A in its detection table.

Cache Line A may be refreshed in any number of ways depending on thecache coherence protocol followed by cache control logic in thecomputing environment. For example, Cache 2 logic may request Cache LineA from Cache 1. For another example, Cache Line A may be cast-out fromCache 1 to shared cache 1450, and Cache 2 logic may request Cache Line Afrom shared cache 1450. Consequently, in embodiments supporting ahigh-conflict indicator associated with each cache line, transactionallyexecuting processors may benefit from high-conflict cache linedeterminations made by other transactionally executing processors in thecomputing environment.

Rather than each processor having separate detection logic foridentifying problematic cache lines in its associated local cache,detection of problematic cache lines may be performed by a centralizeddetector. Embodiments with centralized detection may conserve chip areaand power, and may also avoid design complexities associated with someprocessors managing a cache line in sub-line coherency mode while otherprocessors in the environment manage the same cache line in full-linecoherency mode.

In some embodiments with centralized detection of problematic cachelines, a detection table may be maintained at each coherence point inthe environment. For example, in a computing environment with ahome-node-based cache coherence protocol, one centralized detection unitmay be associated with each home node. In a computing environment with asnooping-based cache coherence protocol, sometimes referred to as asnoopy protocol, there may be one centralized detection unit in thesystem.

FIG. 15 illustrates a high-level view of an example computingenvironment 1500 for centralized detection of high-conflict cache lines,high-coherence-miss cache lines, and other types of problematic cachelines. Computing environment 1500 includes N processor systems 1510communicating over interconnect 1560. Each processor 1520 is associatedwith a low level local cache 1530. The N processors 1520 may also beassociated with one or more high level shared caches 1550 connected in apredetermined topology.

Rather than each processor 1520 having separate detection logic foridentifying problematic cache lines in its associated cache 1530,centralized detector 1540 may track conflicts, coherence misses, and/orother performance-reducing events in centralized detection table 1545.Detector 1540 may monitor communications on interconnect 1560 forindications that a performance-reducing event has occurred, and tracksuch occurrences in detection table 1545. For example, when a processordetects a coherence miss associated with a cache line, it may send arequest for the cache line over interconnect 1560. Detector 1540 maythen detect the request and determine whether the cache line is ahigh-coherence-miss cache line. If detector 1540 determines that thecache line associated with the coherence miss is a high-coherence-misscache line, then the detector will place the cache line in sub-linecoherency mode and notify users of the cache line, for example byasserting a signal or modifying the request with a marker. The signal ormarker may notify the recipient or targets of the message that anyresponse should conform to sub-line coherency mode.

Detection table 1545 is a table of counters that may be used to trackthe number of times any particular cache line is accessed in aparticular manner by any processor associated with the coherence point.For example, detection table 1545 may be a conflict address detectiontable for tracking the number of transaction conflicts associated with aparticular cache line, or may be a coherence miss detection table fortracking the number of coherence misses associated with a particularcache line. In some embodiments, detection table 1545 may be acombination table that can track multiple types of qualifyingcontentions of the cache line. A method similar to example method 1200in FIG. 12 may be used with detection table 1545 to identify problematiccache lines.

Each entry in detection table 1545 corresponds to an individual cacheline in the environment, and may be identified using the same tag usedto identify the cache line in the caches 1530. Each entry may includeone or more counters associated with each cache line. A counter may beincremented by detector 1540 with each qualifying contention of thecache line. The counters may be saturating counters to avoid rollingover to zero if the counters' maximum values are reached. Detectiontable 1545 may be preconfigured to hold a fixed number of entries or maybe of variable or programmable size. In some embodiments, a hash of thetag used in the directory may be used for identification in thedetection table 1545 to reduce the amount of address bits used. In someembodiments, an entry in the detection table 1545 may represent multipleadjacent cache lines.

Ideally, detection table 1545 may be small compared to the cache size;therefore not every cache line in the various caches 1530 or 1550 may betracked in detection table 1545. Qualifying contentions may be one ormore of transaction conflicts, coherence misses, or other types ofcontentions where reducing the cache line size can reduce falsepositives and improve performance. In some embodiments, when a cacheline ages out of all caches 1530 or 1550, any corresponding entries indetection table 1545 may be invalidated.

Detector 1540 may track a single type of qualifying contention ormultiple types. For example, detection table 1545 may be a conflictaddress detection table for identifying high-conflict cache lines, ormay be a coherence miss detection table for identifyinghigh-coherence-miss cache lines. In some embodiments, detector 1540 maytrack more than one type of qualifying contention either individually orcombined. For example, detection table 1545 may have a single entry fora cache line with separate counters for transaction conflicts andcoherence misses. Alternatively, detection table 1545 may have a singleentry for a cache line with a single counter for both transactionconflicts and coherence misses.

FIG. 16 illustrates an example method 1600 for centralized detection ofproblematic cache lines in a computing environment. At start 1610, if acentralized detector monitoring communications on a coherenceinterconnect at 1615 detects a communication at 1620, and if thecommunication indicates that a processor's access of a cache lineresulted in a performance-reducing event at 1630, then the detectordetermines whether the cache line is a highly contended cache line at1640. For example, in environments implementing a snoopy coherenceprotocol, a first processor detecting a transaction conflict of a cacheline may raise a signal on the coherence interconnect to indicate theoccurrence of the transaction conflict. The centralized detectorobserving the signal and/or a response to the signal may then check thecentralized detection table, update a counter in the table, anddetermine whether this particular cache line that is the source of thetransaction conflict is a high-conflict cache line. If the cache line isnot a high-conflict cache line at 1640, for example because a counter inthe detection table associated with the cache line does not satisfy ahigh-conflict criterion, then the detector continues monitoring theinterconnect for the next communication at 1620.

Continuing the example, a second processor detecting a transactionconflict of the same cache line may raise a signal on the coherenceinterconnect to indicate the occurrence of the transaction conflict. Thecentralized detector observing the signal and/or a response to thesignal may then check the centralized detection table and update thesame counter in the table. In embodiments with centralized detection, asingle detector and table can monitor conflicts from multipleprocessors. If the cache line is still not a high-conflict cache line at1640, then the detector continues monitoring the interconnect for thenext communication at 1620.

If the detector determines that the cache line is a high-conflict,high-coherence-miss, or other type of highly contended cache line at1640, then the cache line is placed in sub-line coherency mode at 1650,the detector notifies caches that are requesting or otherwise accessingthe cache line that the cache line is in sub-line coherency mode at1660, and subsequent requests for the cache line will result insub-cache line portions of the cache line being returned at 1670.Placing the cache line in sub-line coherency mode may or may notinclude, for example, setting a flag or other external indicatorassociated with the cache line, or placing an entry representing thecache line in a table or list. Continuing the example above, when thecentralized detector observes a subsequent request for the high-conflictcache line, it may assert a signal indicating that this cache lineshould be placed in sub-line coherency mode. All processors in theenvironment may then observe this signal, and those actively caching thehigh-conflict line will therefore be notified that this cache line is insub-line coherency mode.

For another example, in environments implementing a home-node-basedcoherence protocol, a first processor detecting a transaction conflictof a cache line may send a notice to the home node for the cache lineindicating the occurrence of the transaction conflict. The centralizeddetector at the home node observing the notice may then check thecentralized detection table, update a counter in the table, anddetermine whether this particular cache line that is the source of thetransaction conflict is a high-conflict cache line at 1640. If the cacheline is not a high-conflict cache line, then the detector continuesmonitoring the interconnect for the next communication at 1620.

Continuing the example, a second processor detecting a transactionconflict of the same cache line may send a notice to the home node forthe cache line indicating the occurrence of the transaction conflict.The centralized detector at the home node observing the notice may thencheck the centralized detection table and update the same counter in thetable. If the cache line then satisfies the criterion for ahigh-conflict cache line at 1640, then the cache line is placed insub-line coherency mode at 1650. When the home node receives asubsequent request for the high-conflict cache line, the centralizeddetector may then modify the request to indicate that the cache line isin sub-line coherency mode before the request is forwarded to all activesharers of the cache line.

Although specific examples are given above for how a centralizeddetector may monitor inter-processor communications to detect theoccurrence of qualifying performance-impacting events such astransaction conflicts and coherence misses, and although specificexamples are given of how a centralized detector may notify cache usersthat a particular cache line should be managed in sub-line coherencymode, these are only examples and are not limiting. A computingenvironment's cache coherence protocol will influence the implementationdetails of any suitable process for monitoring communications and fornotifying cache users.

Computing environments supporting a configurable cache line size mayhave caches organized such that all lines in the cache may besimultaneously managed in sub-line coherency mode. Since sub-line cachemanagement requires, at a minimum, a set of descriptive bits thatprovides information about each sub-cache line portion of a cache line,a cache designed to provide for simultaneously managing all lines in thecache in sub-line coherency mode can be wasteful of chip resources whensome cache lines remain in full-line coherency mode. Embodimentsdisclosed herein for identifying problematic cache lines andsubsequently placing those lines in sub-line coherency mode may performoptimally when the majority of cache lines remain in full-line coherencymode.

FIG. 17 illustrates an example cache structure 1700 that may conservechip resources by providing sub-line cache management for less than alllines in an entire cache. The ideal number of cache lines to manage insub-line coherency mode may be determined, for example, throughpre-silicon performance modeling.

Cache 1700 holds a number of cache lines 1720 in a data array component1735, and may include a cache directory 1730 with an entry for eachcache line 1720. For each cache line, the directory may include a tagthat identifies the locations in main memory represented in the cacheline. Although cache 1700 shows a simplified structure with a simpleidentifying tag associated with a single cache line of contiguousmemory, any cache configuration that associates an identifier with aportion of memory is contemplated. Cache directory 1730 may also includea set of full-line descriptive bits that provides information about thecache line when the cache line is in full-line coherency mode. The setof full-line descriptive bits may include a valid bit, a set ofcoherence state bits (for example, MESI bits), transactional accessbits, and other bits describing attributes of the cache line.

In addition, cache structure 1700 may include a side table 1740 formanaging cache lines in sub-line coherency mode while data arraycomponent 1735 remains unchanged. The number of entries in side table1740 may provide an upper limit to the number of cache lines in cachestructure 1700 that may be simultaneously managed in sub-line coherencymode. Side table 1740 may have fewer entries than cache directory 1730,and the ideal number of entries for side table 1740 may be fixed or maybe configurable. Each valid entry in side table 1740 may include a tagand at least one set of sub-line descriptive bits that providesinformation about the sub-cache line portions of a cache line when thecache line is in sub-line coherency mode. The number of sets of sub-linedescriptive bits may depend on the number of sub-cache line portionsinto which a cache line is divided when placed in sub-line coherencymode. Each set of sub-line descriptive bits may be similar or identicalto the set of full-line descriptive bits for the cache line in directory1730, and may include a valid bit, a set of coherence state bits (forexample, MESI bits), transactional access bits, and other bitsdescribing attributes of each sub-cache line portion.

To illustrate, cache line 1750 may be associated with Tag A. When cacheline 1750 is in full-line coherency mode, the set of full-linedescriptive bits in cache directory 1730 provide information about thefull cache line. But if Tag A is also represented in an entry 1751 inside table 1740, then cache line 1750 is in sub-line coherency mode, andthe four sets of sub-line descriptive bits in entry 1751 provideinformation about each sub-cache line portion of cache line 1750. Inthis example, sub-line coherency mode is configured to manage full cachelines as four sub-cache line portions: Bits 1 provide information aboutSub-cache Line 1, Bits 2 provide information about Sub-cache Line 2,Bits 3 provide information about Sub-cache Line 3, and Bits 4 provideinformation about Sub-cache Line 4. In some embodiments, side table 1740may provide one less set of descriptive bits than the number ofsub-cache line portions, and the set of bits from directory 1730 maydescribe one of the sub-cache line portions when the cache line is insub-line coherency mode. If cache line 1750 is later returned tofull-line coherency mode, then entry 1751 in side table 1740 may beinvalidated, and the set of descriptive bits in cache directory 1730 mayonce again be configured to provide information about the full cacheline.

In some embodiments, the determination whether a specific cache line isin sub-line coherency mode is made by inspecting the side table 1740. Ifthe tag associated with a cache line is present in side table 1740, thenthe cache control logic manages the line as a plurality of sub-cacheline portions of the full cache line. If the tag associated with a cacheline is not present in side table 1740, then the cache control logicmanages the line as a full cache line. In such embodiments, the presenceof entries 1751 and 1761 in side table 1740 indicates that cache lines1750 and 1760 are in sub-line coherency mode. In some embodiments, thedetermination whether a specific cache line is in sub-line coherencymode is made by examining an indicator such as indicator 1160 in FIG. 11or in some other manner. Cache control logic inspecting such anindicator or otherwise determining that a specific cache line is insub-line coherency mode would then find the relevant entry in side table1740.

FIG. 18 illustrates an example method 1800 for placing problematic cachelines in sub-line coherency mode using cache structure 1700 from FIG.17. At start 1805, if a logical processor in the computing environmentis performing an operation that will be accessing a cache line at 1815,then the method determines whether the cache line that will be accessedis already in sub-line coherency mode by determining whether the cacheline is represented in the side table at 1820. A cache line may be insub-line coherency mode for any number of reasons. For example, a cacheline may be in sub-line coherency mode because it has been previouslydetermined to be a high-conflict cache line or a high-coherence-misscache line. In some embodiments, the side table and the conventionalcache directory may be accessed in parallel, and information from anentry found in the side table supersedes information from theconventional cache directory.

If the cache line is represented in the side table at 1820, then onlythe relevant sub-cache line portion of the cache line is accessed at1825. The relevant sub-cache line portion is the sub-cache line thatincludes a copy of the memory address targeted in the operation. Theremaining non-relevant sub-cache line portions of the cache line are notaccessed. As an example, for a cache line in sub-line coherency modemanaged as two sub-cache lines, if the processor accesses memory addressA, and if memory address A is associated with the second sub-cache lineportion of the cache line, then only the state of the second sub-cacheline as described by the set of sub-line descriptive bits in the sidetable associated with the second sub-cache line is relevant. The set ofdescriptive bits in the side table associated with the first sub-cacheline is irrelevant. If the cache line is not represented in the sidetable at 1820, then the full cache line is accessed at 1830.

Alternatively at start 1805, if a coherency event is impacting a cacheline at 1810, then the method checks if the cache line has an entry inthe side table at 1833. If an entry already exists, it will be left asis; otherwise, the method determines whether the cache line satisfiescriteria for sub-line coherency mode at 1835. Methods for determiningwhether a cache line satisfies criteria for sub-line coherency mode arediscussed above, and may include, for example, examining a counterassociated with the cache line in a coherence miss detection table or aconflict address detection table.

If the cache line does not satisfy criteria for sub-line coherency modeat 1835, then the cache line remains in full-line coherency mode, andsubsequent operations targeting memory addresses within the cache linewill access the full line. But if the cache line is determined tosatisfy criteria for sub-line coherency mode at 1835, then an entry isadded for the cache line in the side table to place the cache line insub-line coherency mode, and subsequent operations will access sub-cacheline portions of the cache line. If the side table has unused entriesavailable at 1840, then the new entry may be added to the table at 1850.If the side table has no unused entries available at 1840, then anexisting entry may be replaced at 1845. If the new entry is replacing anexisting entry, any suitable protocol for selecting a candidate entryfor replacement may be followed. For example, the least recently used orupdated entry may be replaced, or the entry with the smallest countervalue may be replaced.

In some embodiments, a data processing system suitable for storingand/or executing program code is usable that includes at least oneprocessor coupled directly or indirectly to memory elements through asystem bus. The memory elements include, for instance, local memoryemployed during actual execution of the program code, bulk storage, andcache memory which provide temporary storage of at least some programcode in order to reduce the number of times code must be retrieved frombulk storage during execution.

Input/Output or I/O devices (including, but not limited to, keyboards,displays, pointing devices, DASD, tape, CDs, DVDs, thumb drives andother memory media, etc.) may be coupled to the system either directlyor through intervening I/O controllers. Network adapters may also becoupled to the system to enable the data processing system to becomecoupled to other data processing systems or remote printers or storagedevices through intervening private or public networks. Modems, cablemodems, and Ethernet cards are just a few of the available types ofnetwork adapters.

One or more aspects of the present invention can be included in anarticle of manufacture (e.g., one or more computer program products)having, for instance, computer usable media. The media has therein, forinstance, computer readable program code means or logic (e.g.,instructions, code, commands, etc.) to provide and facilitate thecapabilities of the present invention. The article of manufacture can beincluded as a part of a system (e.g., computer system) or soldseparately.

One example of an article of manufacture or a computer program productincorporating one or more aspects of the present invention is describedwith reference to FIG. 19. A computer program product 1900 includes, forinstance, one or more computer usable media 1902 to store computerreadable program code means or logic 1904 thereon to provide andfacilitate one or more aspects of the present invention. The medium canbe an electronic, magnetic, optical, electromagnetic, infrared, orsemiconductor system (or apparatus or device) or a propagation medium.Examples of a computer readable medium include a semiconductor or solidstate memory, magnetic tape, a removable computer diskette, a randomaccess memory (RAM), a read-only memory (ROM), a rigid magnetic disk andan optical disk. Examples of optical disks include compact disk-readonly memory (CD-ROM), compact disk-read/write (CD-R/W) and DVD.

A sequence of program instructions or a logical assembly of one or moreinterrelated modules defined by one or more computer readable programcode means or logic direct the performance of one or more aspects of thepresent invention.

Although one or more examples have been provided herein, these are onlyexamples. Many variations are possible without departing from the spiritof the present invention. For instance, processing environments otherthan the examples provided herein may include and/or benefit from one ormore aspects of the present invention. Further, the environment need notbe based on the z/Architecture®, but instead can be based on otherarchitectures offered by, for instance, IBM®, Intel®, Sun Microsystems,as well as others. Yet further, the environment can include multipleprocessors, be partitioned, and/or be coupled to other systems, asexamples.

As used herein, the term “obtaining” includes, but is not limited to,fetching, receiving, having, providing, being provided, creating,developing, etc.

The capabilities of one or more aspects of the present invention can beimplemented in software, firmware, hardware, or some combinationthereof. At least one program storage device readable by a machineembodying at least one program of instructions executable by the machineto perform the capabilities of the present invention can be provided.

The flow diagrams depicted herein are just examples. There may be manyvariations to these diagrams or the steps (or operations) describedtherein without departing from the spirit of the invention. Forinstance, the steps may be performed in a differing order, or steps maybe added, deleted, or modified. All of these variations are considered apart of embodiments of the claimed invention.

Although preferred embodiments have been depicted and described indetail herein, it will be apparent to those skilled in the relevant artthat various modifications, additions, substitutions and the like can bemade without departing from the spirit of the embodiments, and theseare, therefore, considered to be within the scope of the embodiments, asdefined in the following claims.

What is claimed is:
 1. A method for reducing transaction conflicts in acomputing environment with transactional memory, the computingenvironment including a cache configured to hold a plurality of cachelines, each cache line configurable with a coherency mode, each cacheline associated with a high-conflict indicator, the method comprising:examining a first high-conflict indicator associated with a first cacheline; based on the examining, placing the first cache line in a sub-linecoherency mode, wherein cache control logic associated with the cache isconfigured to operate or manage a plurality of sub-cache line portionsof the first cache line in the sub-line coherency mode; executing atransaction in the computing environment, the transaction accessing amemory address within the first cache line; and accessing and managing,while executing the transaction, only a relevant sub-cache line portionof the first cache line in the sub-line coherency mode, the relevantsub-cache line portion associated with the memory address, wherein thefirst cache line is a first-cache copy of the first cache line in afirst cache, and wherein the first high-conflict indicator is associatedwith the first-cache copy, the method further comprising: determining,before executing the transaction, that a second-cache copy of the firstcache line in a second cache is a high-conflict cache line; setting asecond high-conflict indicator associated with the second-cache copy;and based on the setting the second high-conflict indicator, setting thefirst high-conflict indicator associated with the first-cache copy. 2.The method of claim 1, wherein the first high-conflict indicator isassociated with a first cache, the method further comprising:determining, before executing the transaction, that the first cache lineis a high-conflict cache line; and setting the first high-conflictindicator associated with the first cache line in the first cache. 3.The method of claim 1, wherein each cache line is associated with aplurality of descriptive bits, the plurality of descriptive bitsincluding the high-conflict indicator.
 4. The method of claim 1, furthercomprising: determining that a reset criterion associated with the firsthigh-conflict indicator is satisfied; resetting the first high-conflictindicator based on the determining that the reset criterion issatisfied; and placing the first cache line in a full-line coherencymode, wherein the cache control logic is configured to operate or managethe first cache line in the full-line coherency mode with a full-linegranularity, the placing based on the determining that the resetcriterion is satisfied.
 5. The method of claim 4, wherein the resetcriterion is selected from the group consisting of: a period of timeelapses; a number of transactions complete; a number of instructionscomplete; and the first cache line is cast out of the cache.
 6. Acomputer system for reducing transaction conflicts in a computingenvironment with transactional memory, the computing environmentincluding a cache configured to hold a plurality of cache lines, eachcache line configurable with a coherency mode, each cache lineassociated with a high-conflict indicator, the computer systemcomprising: a memory; and a processor in communication with the memory,wherein the computer system is configured to perform a method, themethod comprising: examining a first high-conflict indicator associatedwith a first cache line; based on the examining, placing the first cacheline in a sub-line coherency mode, wherein cache control logicassociated with the cache is configured to operate or manage a pluralityof sub-cache line portions of the first cache line in the sub-linecoherency mode; executing a transaction in the computing environment,the transaction accessing a memory address within the first cache line;and accessing and managing, while executing the transaction, only arelevant sub-cache line portion of the first cache line in the sub-linecoherency mode, the relevant sub-cache line portion associated with thememory address, wherein the first cache line is a first-cache copy ofthe first cache line in a first cache, and wherein the firsthigh-conflict indicator is associated with the first-cache copy, themethod further comprising: determining, before executing thetransaction, that a second-cache copy of the first cache line in asecond cache is a high-conflict cache line; setting a secondhigh-conflict indicator associated with the second-cache copy; and basedon the setting the second high-conflict indicator, setting the firsthigh-conflict indicator associated with the first-cache copy.
 7. Thecomputer system of claim 6, wherein each cache line is associated with aplurality of descriptive bits, the plurality of descriptive bitsincluding the high-conflict indicator.
 8. The computer system of claim6, wherein the setting the first high-conflict indicator comprises:casting-out the second-cache copy and the associated secondhigh-conflict indicator from the second cache to a higher level cache;and updating the first-cache copy and the associated first high-conflictindicator in the first cache from the higher level cache.
 9. Thecomputer system of claim 6, wherein the setting the first high-conflictindicator comprises: requesting the second-cache copy from the secondcache; receiving the second-cache copy and the associated secondhigh-conflict indicator from the second cache; and installing thesecond-cache copy and the associated second high-conflict indicator inthe first cache.
 10. The computer system of claim 6, wherein thedetermining that the second-cache copy of the first cache line is thehigh-conflict cache line comprises: incrementing a counter in a conflictaddress detection table associated with the second cache, the counterassociated with the second-cache copy of the first cache line; anddetermining that the incremented counter satisfies a high-conflictcriterion.
 11. The computer system of claim 6, wherein the methodfurther comprises: determining that a reset criterion associated withthe first high-conflict indicator is satisfied; resetting the firsthigh-conflict indicator based on the determining that the resetcriterion is satisfied; and placing the first cache line in a full-linecoherency mode, wherein the cache control logic is configured to operateor manage the first cache line in the full-line coherency mode with afull-line granularity, the placing based on the determining that thereset criterion is satisfied.
 12. The computer system of claim 11,wherein the reset criterion is selected from the group consisting of: aperiod of time elapses; a number of transactions complete; a number ofinstructions complete; and the first cache line is cast out of thecache.
 13. A computer program product for reducing transaction conflictsin a computing environment with transactional memory, the computingenvironment including a cache configured to hold a plurality of cachelines, each cache line configurable with a coherency mode, each cacheline associated with a high-conflict indicator, the computer programproduct comprising: a non-transitory computer readable storage mediumreadable by a processing circuit and storing instructions for executionby the processing circuit for performing a method, the methodcomprising: examining a first high-conflict indicator associated with afirst cache line; based on the examining, placing the first cache linein a sub-line coherency mode, wherein cache control logic associatedwith the cache is configured to operate or manage a plurality ofsub-cache line portions of the first cache line in the sub-linecoherency mode; executing a transaction in the computing environment,the transaction accessing a memory address within the first cache line;and accessing and managing, while executing the transaction, only arelevant sub-cache line portion of the first cache line in the sub-linecoherency mode, the relevant sub-cache line portion associated with thememory address, wherein the first cache line is a first-cache copy ofthe first cache line in a first cache, and wherein the firsthigh-conflict indicator is associated with the first-cache copy, themethod further comprising: determining, before executing thetransaction, that a second-cache copy of the first cache line in asecond cache is a high-conflict cache line; setting a secondhigh-conflict indicator associated with the second-cache copy; and basedon the setting the second high-conflict indicator, setting the firsthigh-conflict indicator associated with the first-cache copy.
 14. Thecomputer program product of claim 13, wherein the method furthercomprises: marking, while executing the transaction, only the relevantsub-cache line portion of the first cache line as transactionallyaccessed.
 15. The computer program product of claim 13, wherein eachcache line is associated with a plurality of descriptive bits, theplurality of descriptive bits including the high-conflict indicator. 16.The computer program product of claim 13, wherein the method furthercomprises: determining that a reset criterion associated with the firsthigh-conflict indicator is satisfied; resetting the first high-conflictindicator based on the determining that the reset criterion issatisfied; and placing the first cache line in a full-line coherencymode, wherein the cache control logic is configured to operate or managethe first cache line in the full-line coherency mode with a full-linegranularity, the placing based on the determining that the resetcriterion is satisfied.
 17. The computer program product of claim 13,wherein the method further comprises: executing a second transaction inthe computing environment, the second transaction accessing a secondmemory address within the first cache line; examining, before completingthe second transaction, the first high-conflict indicator associatedwith the first cache line; based on the examining before completing thesecond transaction, discovering that the first cache line is not ahigh-conflict cache line; based on the discovering that the first cacheline is not a high-conflict cache line, placing the first cache line ina full-line coherency mode, wherein the cache control logic associatedwith the cache is configured to operate or manage the first cache linein the full-line coherency mode with a full-line granularity; andaccessing and managing, while executing the transaction, a full cacheline of the first cache line in the full-line coherency mode.